I've been getting the error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException
When I try to call my webservice 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 quite simple and it looks 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 the call I know the request is not NULL but when it arrives at the webservice it is always received as null. I generated the webservice from WSDL using the wsdl.exe utility and clearly I don't understand all the details of SOAP that I should. Has anyone else run into this issue?
Thanks in advance for any help that anyone is able to provide.