.NET WCF class calling Java created by WSDL, "Method and Type References"

I spent the last couple of days trying to call a third-party web service written in Java from .NET.

I used the svcutil.exe utility to create a proxy class to invoke the web service.

I refrain from publishing WSDL since its length is 2785 lines. The generated proxy class is 8.560 lines long, so I also refrain from posting, but I will talk about some of the comments below and what I did to try to solve the problem.

The SOAP expected by the web service (short for namespace brevity) is as follows:

<s:Envelope>
  <s:Header> ... </s:Header>
  <s:Body>
    <GetAccountDetail>
      <Request>
        ...
      </Request>
    </GetAccountDetail>
  </s:Body>
</s:Envelope>

The SOAP returned by the web service is as follows:

<SOAP-ENV:Envelope>
  <SOAP-ENV:Header />
  <SOAP-ENV:Body>
    <gad:GetAccountDetail>
      <gad:Response>
        ...
      </gad:Response>
    </gad:GetAccountDetail>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

As you can see, the request goes through the element <GetAccountDetail>/<Request>, and the response is issued through the element <GetAccountDetail>/<Response>. The difference is represented by the gad: prefix, which is used for the response.

This means that it is the signature of one of the class files created for the request.

svcutil.
<System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), _
 System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced), _
 System.ServiceModel.MessageContractAttribute(WrapperName:="GetAccountDetail", WrapperNamespace:="http://www.mysite.co.uk/NAC/GetAccountDetail", IsWrapped:=True)> _
Partial Public Class GetAccountDetailWSDLRequest

And here is the response signature

<System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), _
 System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced), _
 System.ServiceModel.MessageContractAttribute(WrapperName:="GetAccountDetail", WrapperNamespace:="http://www.mysite.co.uk/NAC/GetAccountDetail", IsWrapped:=True)> _
Partial Public Class GetAccountDetailWSDLResponse

As you can see, both classes share this decoration:
WrapperName:="GetAccountDetail",WrapperNamespace:="http://www.mysite.co.uk/NAC/GetAccountDetail", IsWrapped:=True

At runtime, the following error appears:

The XML element 'GetAccountDetail' from the namespace 'http://www.mysite.co.uk/NAC/GetAccountDetail' refers to the method and type. Change the name of the method message using WebMethodAttribute or change the root element of the type using XmlRootAttribute.

, , . .

  •  
  • WrapperName/WrapperNamespace , -, - , , ( Fiddler, , XML- )  
  • WrapperName/WrapperNamespace , , , Fiddler - - , , . .NET, .

, , WrapperName, WrapperNamespaces, -, , , .

, WSDL .

wsdl.exe svcutil.exe. , , , InnerException, XML .

- wsdl proxy, , , . , , .

+3

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


All Articles