Bug 16256 - Missing element in WSDL in response of ServiceContract
Summary: Missing element in WSDL in response of ServiceContract
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-11-15 06:12 UTC by pete
Modified: 2017-09-06 16:55 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description pete 2013-11-15 06:12:54 UTC
WSDL produced from ServiceContracts appears to omit the data element descriptions. This causes problems for anything that uses the WSDL to parse messages later on.

This was seen on Mono 3.2.3 on Linux but it has been on all recent versions we have tried.

A simple example with the following code to produce the service description:

[ServiceContract(Namespace = "urn:Test", Name = "Calculator")]
public interface ICalculator
{
	[OperationContract]
	AddResponse Add(Add ar);
}

[MessageContract(IsWrapped = true, WrapperName = "Add", WrapperNamespace = "urn:Test")]
public class Add
{
	[MessageBodyMember]
	public double n1;

	[MessageBodyMember]
	public double n2;
}


[MessageContract]
public class AddResponse
{
	[MessageBodyMember]
	public double Result;

	public AddResponse()
	{
		Result = 0;
        }

	public AddResponse(double res)
	{
		this.Result = res;
	}
}


produces this WSDL (in the ?xsd=xsd1 file)

- <xs:schema xmlns:tns="urn:Shout" elementFormDefault="qualified" targetNamespace="urn:Shout" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="Add">
- <xs:complexType>
- <xs:sequence>
  <xs:element minOccurs="0" name="n1" type="xs:double" /> 
  <xs:element minOccurs="0" name="n2" type="xs:double" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
- <xs:element name="AddResponse">
- <xs:complexType>
  <xs:sequence /> 
  </xs:complexType>
  </xs:element>
  </xs:schema>

I.e. the data in the request (n1 and n2) is in there, but not the response (Result). Running exactly the same code with .Net, it is there.
Comment 1 pete 2014-08-22 10:17:14 UTC
I have discovered this is easy to fix in:

mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlExporter.cs

Function: ExportParameters

Add parameters also if msgbody.ReturnValue != null and  (msgbody.ReturnValue.Type == typeof (void) (both else clauses)




i.e:


if (msgbody.ReturnValue == null) {
  foreach (MessagePartDescription part in msgbody.Parts)
  ...

} else {
   if (msgbody.ReturnValue.Type != typeof (void)) {
   ....
   } 
   **ADD** else {
    foreach (MessagePartDescription part in msgbody.Parts)... (same as above)
  }   
}

Note You need to log in before you can comment on or make changes to this bug.