How to send/receive SOAP request and response using C#?

前端 未结 1 1668
慢半拍i
慢半拍i 2020-12-13 10:17
private static string WebServiceCall(string methodName)        
{
    WebRequest webRequest = WebRequest.Create(\"http://localhost/AccountSvc/DataInquiry.asmx\");
           


        
相关标签:
1条回答
  • 2020-12-13 10:48

    The urls are different.

    • http://localhost/AccountSvc/DataInquiry.asmx

    vs.

    • /acctinqsvc/portfolioinquiry.asmx

    Resolve this issue first, as if the web server cannot resolve the URL you are attempting to POST to, you won't even begin to process the actions described by your request.

    You should only need to create the WebRequest to the ASMX root URL, ie: http://localhost/AccountSvc/DataInquiry.asmx, and specify the desired method/operation in the SOAPAction header.

    The SOAPAction header values are different.

    • http://localhost/AccountSvc/DataInquiry.asmx/ + methodName

    vs.

    • http://tempuri.org/GetMyName

    You should be able to determine the correct SOAPAction by going to the correct ASMX URL and appending ?wsdl

    There should be a <soap:operation> tag underneath the <wsdl:operation> tag that matches the operation you are attempting to execute, which appears to be GetMyName.

    There is no XML declaration in the request body that includes your SOAP XML.

    You specify text/xml in the ContentType of your HttpRequest and no charset. Perhaps these default to us-ascii, but there's no telling if you aren't specifying them!

    The SoapUI created XML includes an XML declaration that specifies an encoding of utf-8, which also matches the Content-Type provided to the HTTP request which is: text/xml; charset=utf-8

    Hope that helps!

    0 讨论(0)
提交回复
热议问题