wcf
wcf copied to clipboard
SVCUTIL generates methods without arguments
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]
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.
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.
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:
-
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>
-
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.
Thank you, is there no workaround to also add the header?
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.
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.