0

I'm facing a problem when trying to generate a proxy client in C# .Net 4.0 for the webservice defined by this wsdl: link (I'm not managing this service and it seems to be an Axis2 MTOM Java based service)

Here is the generator feedback:

1):
Details: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Object reference not set to an instance of an object.
XPath to the source of error: //wsdl:definitions[@targetNamespace='http://sls.ws.coliposte.fr']/wsdl:portType[@name='ServiceV3WS']

2):
Error: Unable to import wsdl:binding
Detail: An error occurred while importing wsdl:portType which depends wsdl:binding.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://sls.ws.coliposte.fr']/wsdl:portType[@name='ServiceV3WS']
XPath to the source of error: //wsdl:definitions[@targetNamespace='http://sls.ws.coliposte.fr']/wsdl:binding[@name='SlsServiceWSSoapBinding']

3):
Error: Unable to import wsdl:port
Detail: An error occurred while importing wsdl:binding which depends wsdl:port.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://sls.ws.coliposte.fr']/wsdl:binding[@name='SlsServiceWSSoapBinding'] 
XPath to the source of error: //wsdl:definitions[@targetNamespace='http://sls.ws.coliposte.fr']/wsdl:service[@name='SlsServiceWS']/wsdl:port[@name='SlsServiceWSPort']
  1. These errors seem cryptic to me, but it seems the errors 2 and 3 depend from the error 1. So my hypothesis was first this service was not compliant (for instance, portType was not defined with the right path). So I tried to validate it using a wsdl validator (I tried wsdl-analyzer.com) and it returns me that all was OK.
  2. So my second hypothesis was that I generate the proxy in a wrong way:
    • I tried using the "standard WCF way" via the "add service reference" menu option from Visual Studio (2012).
    • I also try generate a client proxy using svcutil.exe (v 4.0.30319.xxx). Obviously, it returns the same errors. (It seems svcutil is used in backend by VS.)

What I expect:

Well, I've seen many related questions on SO about this kind of proxy generation. But my main problem is I don't really understand what is the actual problem. So I decide to post a new question to request explanation about these errors: what do they mean, why such errors appear and what are the alternative ways/tools to generate such proxy.

So this is my first post on SO so feel free to review and comment.

Thank you by advance and see you.

Abdur Rahman
  • 353
  • 5
  • 16
CLallier
  • 41
  • 5

1 Answers1

4

It takes me a few hours to find information about this problem, I've found answers to my questions and solving it.

I looked at the svcutil.exe documentation page and tried options that looks fit the best with my problem ("randomly" is the actual term).

After a few trial-error cycles it seems that the option /serializer:XmlSerializer that "generates data types that use the XmlSerializer for serialization and deserialization" was missing to my case. For information the default value is /serializer:Auto that "generates classes marked with the Serializable Attribute".

Regarding my previous questions, I can say:

  • Understanding of the problem: right now, these errors are still cryptic to me. This "Object reference not set to an instance of an object" was not really a good descriptor of the "real" problem. Maybe the name of the incriminate class System.ServiceModel.Description.DataContractSerializerMessageContractImporter was a clue I missed.

  • Alternatives to build such a proxy: svcutil is an alternative to the default "add service reference" menu option. It permits to use a custom set of options according to the context of the targeted service. As a drawback, it is far less integrated into the regular workflow of the Visual Studio architecture. So one has to integrate "manually" the output proxy classes generated and its configuration file. Thus, each time the proxy will be updated, which is finally not an impossible task.

To conclude, maybe an improvement to do is to let user configure its own set of parameters inside the VS generation UI (If you see this thread and work at Microsoft on the VS project, you know what to do :))

Thank you. Expecting this answer could help anyone in a similar situation.

CLallier
  • 41
  • 5