1
votes

I am trying to migrate some server code from .Net 4.7 to .Net Core 3.1 so we can run on a Linux host.

There are two connected services using SOAP. One has ported with zero changes but other has errors when importing using the WSDL file:

http://uat.risc.enexusrental.co.uk/SOAP/IndividualService.php?wsdl

I'm not a SOAP expert and have only ever used the code generated by importing WSDL files so the errors don't mean a lot to me.

Cannot import wsdl:port Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on. XPath to wsdl:binding: wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpPost'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:service[@name='IndividualService']/wsdl:port[@name='IndividualServiceHttpPost'] Cannot import wsdl:binding Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled. XPath to Error Source: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpPost'] Cannot import wsdl:port Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on. XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpGet'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:service[@name='IndividualService']/wsdl:port[@name='IndividualServiceHttpGet'] Cannot import wsdl:binding Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled. XPath to Error Source: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpGet']

To simplify debugging I created simple command line apps, one for .Net 4.7 and the other Core 3.1.

Importing worked perfectly for the .Net 4.7 and I can call the service (as expected).

Importing for Core 3.1 gives the errors as above and when calling the client initialization it returns an error of:

Client.Channel = 'Client.Channel' threw an exception of type 'System.ServiceModel.CommunicationObjectFaultedException'

I get the same errors when importing using svcutil.exe manually.

After 3 days Googling I am no further on as each problem seems to be different and none of the solutions work.

Would someone be kind enough to explain what these errors actually mean (I'm not a SOAP expert) and, if possible, what I sort of things I need to do to work around them?

2
@Gusman Thanks for the suggestion, but my code has no XHttpBinding that appears to be the solution for them.DaveEP
No, but your problem is the same, various bindings that aren't supported by .net core, ex: /wsdl:binding[@name='IndividualServiceHttpGet']Gusman
So these should be removed from the WSDL before trying to import? I'm a novice with WSDL so not exactly sure what to do.DaveEP

2 Answers

1
votes

Download the WSDL to a file and remove the unsupported GET and POST bindings manually by removing the corresponding wsdl:binding and wsdl:port elements. You can then use the tools (dotnet-svcutil or Visual Studio / IDEs) to generate the client code (Service Reference).

    --- a/service.wsdl
    +++ b/service.wsdl
    @@ -286,37 +286,6 @@
           </wsdl:output>
         </wsdl:operation>
       </wsdl:binding>
    -  <wsdl:binding name="IndividualServiceHttpGet" type="tns:IndividualServiceHttpGet">
    -    <http:binding verb="GET" />
    -    <wsdl:operation name="SearchByLastNameAndDateOfBirth">
    -      <http:operation location="/SearchByLastNameAndDateOfBirth" />
    -      <wsdl:input>
    -        <http:urlEncoded />
    -      </wsdl:input>
    -      <wsdl:output>
    -        <mime:mimeXml part="Body" />
    -      </wsdl:output>
    -    </wsdl:operation>
    -    <wsdl:operation name="SearchByDrivingLicenceNumber">
    -      <http:operation location="/SearchByDrivingLicenceNumber" />
    -      <wsdl:input>
    -        <http:urlEncoded />
    -      </wsdl:input>
    -      <wsdl:output>
    -        <mime:mimeXml part="Body" />
    -      </wsdl:output>
    -    </wsdl:operation>
    -    <wsdl:operation name="Get">
    -      <http:operation location="/Get" />
    -      <wsdl:input>
    -        <http:urlEncoded />
    -      </wsdl:input>
    -      <wsdl:output>
    -        <mime:mimeXml part="Body" />
    -      </wsdl:output>
    -    </wsdl:operation>
    -  </wsdl:binding>
    -  <wsdl:binding name="IndividualServiceHttpPost" type="tns:IndividualServiceHttpPost">
         <http:binding verb="POST" />
         <wsdl:operation name="SearchByLastNameAndDateOfBirth">
           <http:operation location="/SearchByLastNameAndDateOfBirth" />
    @@ -354,11 +323,5 @@
         <wsdl:port name="IndividualServiceSoap12" binding="tns:IndividualServiceSoap12">
           <soap12:address location="http://uat.risc.enexusrental.co.uk/SOAP/IndividualService.php" />
         </wsdl:port>
    -    <wsdl:port name="IndividualServiceHttpGet" binding="tns:IndividualServiceHttpGet">
    -      <http:address location="http://uat.risc.enexusrental.co.uk/SOAP/IndividualService.php" />
    -    </wsdl:port>
    -    <wsdl:port name="IndividualServiceHttpPost" binding="tns:IndividualServiceHttpPost">
    -      <http:address location="http://uat.risc.enexusrental.co.uk/SOAP/IndividualService.php" />
    -    </wsdl:port>
       </wsdl:service>
     </wsdl:definitions>
0
votes

I face similar problem afterwards I utilize "svcutil" and created a batch file with below command

"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\svcutil.exe" <your service address/url like http://localhost:*****/***/**/***** >  /o:"<name of class file to be created>.cs" /r:"..\..\<Any reference assembly if any otherwise leave this>" /n:*,<targetNamespace>  /ct:<collectionType:<type> like System.Collections.Generic.List`1>

for more information on svcutil go to dev command of VS and run command: svcutil/?