wcf icon indicating copy to clipboard operation
wcf copied to clipboard

SVCUTIL generates methods without arguments

Open Axeltherabbit opened this issue 1 year ago • 6 comments
trafficstars

Describe the bug Broken class is generated from wsdl

To Reproduce I'm importing this webservice in visual studio: https://api.learningassistant.com/webservices/soap/company.cfc?wsdl the methods that are generated don't have any arguments

Expected behavior A working class is generated

Additional context version: [Microsoft.Tools.ServiceModel.Svcutil, Version 2.2.0-preview1.23462.5]

Axeltherabbit avatar Mar 28 '24 16:03 Axeltherabbit

I have tried running the tool against the given wsdl and encountered below warnings, the warnings indicate that the wsdl file contains some elements that are not supported by the tool, this might result in incomplete or incorrect code generation.

Warning: Fault named CFCInvocationException in operation GetCompanies cannot be imported. Unsupported WSDL, the fault message part must reference an element.
Warning: Headers are not supported in RPC encoded format. Headers are ignored in message GetCompaniesRequest.

Svcutil.exe and dotnet-svcutil.exe behave the same, so it doesn't seem to be regression issue of dotnet-svcutil tool.

imcarolwang avatar Mar 29 '24 09:03 imcarolwang

What do you advice? Is there an easy way to self implement the custom header and the missing arguments? I didn't find much online about it.

I also noticed that the arguments are generated correctly when the method is generated async but they aren't present if I generate a sync method.

Axeltherabbit avatar Mar 29 '24 12:03 Axeltherabbit

Hi, as per this warning message "Unsupported WSDL, the fault message part must reference an element." , I tried to fix it by saving the WSDL locally and do below updates to the file:

  1. update from <wsdl:message name="CFCInvocationException"> <wsdl:part name="fault" type="tns2:CFCInvocationException"/> </wsdl:message> to <wsdl:message name="CFCInvocationException"> <wsdl:part name="fault" element="tns2:CFCInvocationException"/> </wsdl:message>

  2. Since element="tns2:CFCInvocationException" is not defined, add the element for CFCInvocationException right below its type definition:

    <element name="CFCInvocationException" nillable="true" type="tns2:CFCInvocationException"/>

With the updates, dotnet-svcutil generates both sync and async operations with arguments.

Hope this helps.

imcarolwang avatar Apr 01 '24 03:04 imcarolwang

Thank you, is there no workaround to also add the header?

Axeltherabbit avatar Apr 03 '24 09:04 Axeltherabbit

Thank you, is there no workaround to also add the header?

Running the dotnet-svcutil tool with --messageContract (short form: -mc) option to generate message contract types for the given wsdl will have the message header data generated. However, it might not work as expected, since the service uses legacy SOAP encoding style of XML and according to this document , WCF allows you to use the legacy SOAP encoding style of XML, however, its use is not recommended, one of the considerations is that MessageHeaderAttribute is incompatible with SOAP encoding.

imcarolwang avatar Apr 24 '24 02:04 imcarolwang

Thank you, yes I get the header this way but it doesn't generate the methods properly, I reported these issues to the API providers, hopefully they are able to fix it.

Axeltherabbit avatar Apr 24 '24 14:04 Axeltherabbit