Handling different SOAP response element names
WCF expects the name of a returned value to be in a specific format by default, but a service might not return an element with its name in the expected format.
WCF has the convention of expecting the returned value to be named in the following format: methodName Result where methodName is the name of the service operation. For example, for a service called getQuote, WCF expects the response to be called: getQuoteResult .However, the service can return an element with a name that does not conform to this format.
When running the scvutil tool to generate a proxy client, if the WSDL specifies a different name, then the proxy interface adds parameters to instruct WCF with the name to look for. For example:[System.ServiceModel.OperationContractAttribute(Action = "", ReplyAction = "*")] [System.ServiceModel.XmlSerializerFormatAttribute(Style = System.ServiceModel.OperationFormatStyle.Rpc, Use = System.ServiceModel.OperationFormatUse.Encoded)] [return: System.ServiceModel.MessageParameterAttribute(Name = "getQuoteReturn")] float getQuote(string in0);
If you create your own interface (for example, by adding a request-reply method to an existing proxy interface), then you must ensure that you add the same parameters to the interface if the service returns a different name. If we do not do so, then the most common issue is that a call to the service method always returns a null value; if an object is returned, then the method returns null, but if a numeric value such as an integer is returned, then the method returns 0.