Reputation: 1386
It seems simple, but I really have a confusion regarding the element and name attributes of wsdl:part
. This is part of the service code in C#:
Interface:
[ServiceContract(Namespace = "http://example.org/virtualfoo")]
public interface IRestFooService
{
[OperationContract]
[WebInvoke(UriTemplate = "getFoo", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
getFooResponseMess getFoo(getFooRequest request);
}
Service:
[ServiceBehavior(Namespace = "http://example.org/virtualfoo")]
public class RestFooService: IRestFooService
{
public getFooResponseMess getFoo(getFooRequest request)
{
// code
}
}
Complex Type:
[System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
public partial class getFooResponseMess
{
[System.ServiceModel.MessageBodyMember(Namespace = "http://example.org/virtualfoo")]
public getFooResponse getFooResponse;
public getFooResponseMess()
{
}
public getFooResponseMess(getFooResponse getFooRes)
{
this.getFooResponse = getFooRes;
}
}
The getFooResponse
class is another complex type (custom class)
I have a WCF but when I see the wsdl structure I want to differentiate or customize this part:
I have this:
...
<wsdl:message name="getFooResponseMess">
<wsdl:part element="tns:getFooResponse" name="getFooResponse"/>
</wsdl:message>
...
But I want this:
...
<wsdl:message name="getFooResponseMess">
<wsdl:part element="tns:getFooResponse" name="getFooResult"/>
</wsdl:message>
...
Apparently if I change the property name of the class of the complex type (getFooResponseMess
) it changes both the name
and the element
attribute:
[System.ServiceModel.MessageBodyMember(Namespace = "http://example.org/virtualfoo")]
public getFooResponse getFooResponseTest; // Change
Wsdl Output:
...
<wsdl:message name="getFooResponseMess">
<wsdl:part element="tns:getFooResponseTest" name="getFooResponseTest"/>
</wsdl:message>
...
But is it possible to have different values? How can I do it? I would like to know what my mistake is and why this happens
I have looked for other questions but the solution of this one did not work in my case: Changing wsdl:part name
Upvotes: 0
Views: 1297
Reputation: 3954
WCF allows you to use the legacy SOAP encoding style of XML, however, its use is not recommended. When using this style (by setting the Use property to Encoded on the System.ServiceModel.XmlSerializerFormatAttribute applied to the service contract), the following additional considerations apply:
The message headers are not supported; this means that the attribute MessageHeaderAttribute and the array attribute MessageHeaderArrayAttribute are incompatible with SOAP encoding.
If the message contract is not wrapped, that is, if the property IsWrapped is set to false, the message contract can have only one body part.
The name of the wrapper element for the request message contract must match the operation name. Use the WrapperName property of the message contract for this.
The name of the wrapper element for the response message contract must be the same as the name of the operation suffixed by 'Response'. Use the WrapperName property of the message contract for this.
Upvotes: 1