0

I have a address: https://103.9.200.73/DPWS_GIP of third party web service that provides ...(provides what?)... . I want to build one web service similar. When I use Firefox to open that link the server is responding with:

<env:Envelope>
    <env:Body>
        <env:Fault>
            <faultcode>env:Client</faultcode>
            <faultstring>Internal Error</faultstring>
        </env:Fault>
    </env:Body>
</env:Envelope>

I had to sear and referenced topics:

  1. How to call a web service with no wsdl in .net

SOME IMAGE I WANT TO PROVIDE - please specify what the image shows!

If I run my web service: The remote server returned an error: (500) Internal Server Error" at code line: using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())

Community
  • 1
  • 1
sonvh
  • 1
  • 2
  • I've tried to edit your question making it better understandable. But there are some informations missing, so please provide them. Also please provide the stack trace of your server. – Marvin Emil Brach Mar 12 '15 at 09:03
  • Hi Marvin Emil Brach, – sonvh Mar 12 '15 at 09:27
  • (provides what?) -> General Department of Taxation give 1 address of webservice (app.config) : – sonvh Mar 12 '15 at 09:51
  • I don't know code General Department of Taxation' WebService, because They don't provide source for me. I want to call webservice without wsdl or asmx on my local: 127.0.0.1:2476/WebService1.asmx Current, I use HttpWebRequest class , but My code has a bug at Server Respone: 500. I don't find cause for this problem. – sonvh Mar 12 '15 at 09:52

1 Answers1

0

Code of my web service

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Net;
using System.Xml;
using System.IO;
using System.Text;
using System.Collections.Specialized;


namespace WSHelloWord
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]   
    public class WebService1 : System.Web.Services.WebService
    {
        [WebMethod]
        public void PostXml(string url)
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?><soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><soap:Body><HelloWorld3 xmlns=""http://tempuri.org/""><parameter1>test</parameter1><parameter2>23</parameter2><parameter3>test</parameter3></HelloWorld3></soap:Body></soap:Envelope>";
            byte[] bytes = Encoding.UTF8.GetBytes(xml);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentLength = bytes.Length;
            request.ContentType = "text/xml";

            using (Stream requestStream = request.GetRequestStream())
            {
                requestStream.Write(bytes, 0, bytes.Length);
            }

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    string message = String.Format("POST failed with HTTP {0}",
                                                   response.StatusCode);
                    throw new ApplicationException(message);
                }
            }
        }

    }
}
sonvh
  • 1
  • 2