System.Web.Services.Protocols.SoapException: The server could not process the request. ---> System.ArgumentNullException

I get an error message:

System.Web.Services.Protocols.SoapException: The server could not process the request. ---> System.ArgumentNullException

When I try to call my web service using the following code:

{
//Create an echoSync request - set the services.
ServiceNameType sourceService = new ServiceNameType {Service = "echoSync", OnBehalfOf = "Source"};
ServiceNameType destService = new ServiceNameType {Service = "echoSync", OnBehalfOf = "Destination"};

//Create the request.
SDD2RequestType request = new SDD2RequestType
                  {
                      AppId = "echoSync",
                      SourceService = sourceService,
                      DestService = destService,
                      RequestId = "1",
                      RequestBody = "Ping"
                  };

//Create the originator.
originator originator = new originator {id = "123456789"};

//Create the transport.
SDD2Transport transport = new SDD2Transport {originatorValue = originator};

//Send the request.
SDD2ResponseType response = null;
response = transport.SDD2TransportOp(request);

//Write out the response.
System.Console.WriteLine(response.ResponseBody.ToString());
}

My webservice method is pretty simple and looks something like this:

    [System.Web.Services.Protocols.SoapHeaderAttribute("originatorValue", Direction = System.Web.Services.Protocols.SoapHeaderDirection.InOut)]
    [System.Web.Services.WebMethodAttribute()]
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://memberdirect.net/SDD2/Transport", RequestElementName = "SDD2Transport", RequestNamespace = "http://cucbc.com/sdd2/transport/", ResponseElementName = "SDD2TransportResponse", ResponseNamespace = "http://cucbc.com/sdd2/transport/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Default)]
    [return: System.Xml.Serialization.XmlElementAttribute("SDD2Response", Namespace = "http://cucbc.com/sdd2/")]
    public override SDD2ResponseType SDD2TransportOp(SDD2RequestType SDD2Request)
    {
        if (SDD2Request == null) throw new ArgumentNullException("SDD2Request");
        var response = new SDD2ResponseType();

        switch (SDD2Request.AppId)
        {
            case "echoSync":
                response.AppId = SDD2Request.AppId;
                response.ProcessingStatus = ProcessingStatusType.Complete;
                response.RequestId = SDD2Request.RequestId;
                response.ResponseBody = "Pong";
                break;
            default:
                throw new System.NotImplementedException();
                break;
        }

        return response;
    }

When I make a call, I know that the request is not NULL, but when it arrives at the web service, it is always accepted as null. I created the webservice from WSDL using the wsdl.exe utility and obviously do not understand all the details of SOAP that I have to. Anyone else run into this issue?

+3
source share
4 answers

, , , , .

, , , , . Wireshark .

+1

, . , .

, RequestElementName . , RequestElementName , , , .

, RequestElementName = "SDD2Transport" SDD2TransportOp.

, , : ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Default, Wrapped, , ElementName .

, ​​ .NET SOAP, , - ( SOAP), .

# , , RequestElementName. , WSDL, .

+1

Wireshark Configurator, , - .

, , , , - .

0

" null" , , . , XML, . , , .

№1 - " -".

0

Source: https://habr.com/ru/post/1703466/


All Articles