1

I received a WSDL from a customer and created a proxy class that I can use in .NET. The WSDL contains one call with a large number of parameters.

In my code, I collect data from entities in Microsoft CRM. Some of the fields in the entities are mandatory and others are not. The result is that I can retrieve an entity with missing (non-mandatory) fields that I have to send through the SOAP interface.

The generated proxy class contains the signature of the method with the large number of parameters. When I call the method with a reference type parameter that is "null", it works just fine. Sometimes a value type parameter is "null" (not returned in the entity). I can't call the generated method in the proxy class because the (value type) parameters of the method in the proxy are not nullable.

Is it possible to use nullable types (bool?, long?) on the .NET side that will result in '< s:element minOccurs="0"' attributes on the SOAP side?

My problem is not solved with the answer from this question: Can I have an optional parameter for an ASP.NET SOAP web service That question relates to one optional parameter. That can be solved with overloads. In my case, the signature has more than 30 parameters and 7 of them are value types that sometimes have no value. If I implement that with overloads, I need 128 overloaded methods to match all combinations.

I tried to make the parameters optional in the proxy class:

long accountCountry, [System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]long? accountLegalForm, string accountName,

This resulted in an System.InvalidOperationException "Method xxx can not be reflected." with an inner exception "There was an error reflecting 'accountLegalForm'."

Community
  • 1
  • 1
  • Is this what you're looking for? http://stackoverflow.com/questions/7565842/web-service-method-with-optional-parameters – Jonathan Carroll Dec 09 '15 at 19:59
  • No, that is not what I am looking for. The call has 33 parameters with 7 value types that can be "missing". I can't solve this with overloading... – Gaston Rommens Dec 09 '15 at 20:23
  • Possible duplicate of [Can I have an optional parameter for an ASP.NET SOAP web service](http://stackoverflow.com/questions/1723052/can-i-have-an-optional-parameter-for-an-asp-net-soap-web-service) – Daniel Corzo Dec 09 '15 at 21:47

0 Answers0