wcf icon indicating copy to clipboard operation
wcf copied to clipboard

dotnet-svcutil doesn't unwrap certain method signatures

Open christopherseeley opened this issue 6 years ago • 2 comments

WSDL contracts with methods that return an array don't get "unwrapped" by dotnet-svcutil.

For example, a method with the following request/response wrappers:

<element name="updateFoos">
  <complexType>
    <sequence>
      <element maxOccurs="unbounded" minOccurs="0"
        name="foos" type="tns:Foo"/>
    </sequence>
  </complexType>
</element>
<element name="updateFoosResponse">
  <complexType>
    <sequence>
      <element maxOccurs="unbounded" minOccurs="0" name="rval" type="tns:Foo" />
    </sequence>
  </complexType>
</element>

Generates this interface method:

 System.Threading.Tasks.Task<ServiceReference1.updateFoosResponse> updateFoosAsync(ServiceReference1.updateFoosRequest request);

Instead of unwrapping the request and response like this:

 System.Threading.Tasks.Task<ServiceReference1.Foo[]> updateFoosAsync(ServiceReference1.Foo[] foos);

Other methods are properly unwrapped. See attached example WSDL to reproduce: FooService.wsdl.txt

christopherseeley avatar Mar 29 '18 18:03 christopherseeley

Hi @christopherseeley Thank you for reporting this issue. We will look at it as soon as we have a chance.

mlacouture avatar Mar 29 '18 21:03 mlacouture

We found some more information on this topic. We got a similar issue with using nullable types but on reproduction we noticed the following behavior:

Generating with the DataContractSerializer:

  • Arrays don't get unwrapped as you mentioned
  • Nullable types get unwrapped correctly

Generating with the XmlSerializer:

  • Arrays get unwrapped properly
  • Nullable types don't get unwrapped in a similar manner

An example for this issue with the XmlSerializer:

<xs:element name="createFoo">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="0" name="foo" nillable="true" type="xs:int" />
        </xs:sequence>
    </xs:complexType>
</xs:element><xs:element name="createFooResponse">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="0" name="createFooResult" type="xs:int" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

which is being generated like this in the interface:

System.Threading.Tasks.Task<ServiceReference.createFooResponse> createFooAsync(ServiceReference.createFooRequest request);

Instead of the expected:

System.Threading.Tasks.Task<int> createFooAsync(int? foo);

So as a work around for you @christopherseeley you could use the xmlSerializer as long as you don't have nullable types

Is there any possibility to increase the priority for this issue? We use both arrays and nullables, therefore we have to invest a lot of time to correct these manually.

Edit: Added the example WSDL for reproduction Service.wsdl.txt

zFAdler avatar Jun 21 '22 08:06 zFAdler