Getting error in proxy while using enumeration data contract

Topics: General Discussion Forum, July and December Releases Forum, Service Factory Modeling Edition Forum
Jun 30, 2008 at 2:23 PM
Edited Jun 30, 2008 at 3:01 PM
Hi,

I am using WSSF in VS 2005. When I use enumeration data contract , proxy contains two enumerations for enum data contract which leads to build failure. I am using svcutil to generate proxy and as a work around I am using /r switch with svcutil but this forces me to have referencre of datacontract dll on client (where proxy is used).

Any insight into this issue will be of great help.

Thanks,
vverma01
Jul 1, 2008 at 4:24 PM
Hi, are you saying that the Service Factory generates the same enumeration twice in the client proxy? I have tried to reproduce this issue by defining an enumeration in the Data Contract model and then using it as a part for an operation message. The generated proxy using the WSSF is valid, there is only one enumeration in my sample that looks like the code snippet below. Let me know if these steps are not lined up with your scenario.

Thanks

 

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.1434")]
[System.
SerializableAttribute()]
[System.Xml.Serialization.
XmlTypeAttribute(Namespace = url:Thread30510)]
public enum ContactType
{
        /// <remarks/>
        Mobile,
        /// <remarks/>
        Home,
        /// <remarks/>
        Business,
}

 

Jul 3, 2008 at 3:34 PM
Hi,

Thanks for your attention.

I am getting following two enums (Same name) in my proxy file which results in compilation error:

    [System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "3.0.4506.30")]
    [System.SerializableAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:x.y.datacontracts")]
    public enum CarConjunction
    {
       
        /// <remarks/>
        AND,
       
        /// <remarks/>
        OR,
    }

+
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Namespace="urn:x.y.datacontracts")]
    public enum CarConjunction : int
    {
       
        [System.Runtime.Serialization.EnumMemberAttribute()]
        AND = 0,
       
        [System.Runtime.Serialization.EnumMemberAttribute()]
        OR = 1,
    }

I am using svcutil for proxy generation.
Do let me know if you need any more info.

Regards,
vverma01

Jul 3, 2008 at 7:27 PM
First of all, is there any particular reason why you are not using the Generate Proxy feature from WSSF?

Regarding the sample you sent, it is a bit strange that each enum is decorated with a different serializer. Can you please provide the code snippet for this enumeration as it shows up in the Data Contract Project? In addition, it could be good to know which ImplementationTechnology have you set for the Data Contract and the Service Contract Models, and also the Serializer Type in the latter.

Thanks
Jul 4, 2008 at 1:09 PM

Hi,

I assume that by "Generate Proxy feature from WSSF" you are referring to "Add service reference". This was generating bindinglist where ever Array was specified in datacontract model. Thats why we had to use svcutil explicitly.

Following is the generated code from datacontract model:

//------------------------------------------------------------------------------

// <auto-generated>

// This code was generated by a tool.

//

// Changes to this file may cause incorrect behavior and will be lost if

// the code is regenerated.

// </auto-generated>

//------------------------------------------------------------------------------

using

System;

 

using

WcfSerialization = global::System.Runtime.Serialization;

 

namespace

c.r.service.datacontracts

 

{

 

/// <summary>

 

 

/// Data Contract Enum - CarConjunction

 

 

/// </summary>

 

[WcfSerialization::DataContract(Namespace =

"urn:c.r.datacontracts", Name = "CarConjunction")]

 

 

public enum CarConjunction

 

{

 

[WcfSerialization::EnumMember(Value=

"AND")]

 

AND = 0,

 

[WcfSerialization::EnumMember(Value=

"OR")]

 

OR = 1,

}

}

Implementation technology : WCF
Serialisation used: DataContractSerializer

Thanks,
vverma01

Jul 7, 2008 at 9:31 PM

Hi vverma01, by "Generate Proxy feature from WSSF" I meant the recipe that you can execute through the Host Model. You can locate it using the Host Explorer under the Client-->Proxy element.


There is another developer describing a similar issue on a different thread, so we are going to unify both discussions into this one. Can you both please confirm the following things:

  • Verify that the output of the generated proxy using the svcutil is the same as the one generated using the WSSF. Meaning, both show up with the duplicated property.
  • If that is the case, then due to the way the proxy is generated in the factory (it uses the exposed WSDL), I would need you to verify in the WSDL that all message parts referencing this duplicated property are pointing to the same namespace:type in their element attribute. For instance, this is how the messages look like in the sample that I have created to reproduce this scenario:

- <wsdl:message name="Message">
      <wsdl:part name="Contact" element="tns:Contact" /> 
  </wsdl:message>
- <wsdl:message name="Message1">
      <wsdl:part name="Contact" element="tns:Contact" /> 
  </wsdl:message> 

As you can see both messages point to the same type, which is has a unique representation in the associated schema:

- <xs:schema elementFormDefault="qualified" targetNamespace="url:Thread30510" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="url:Thread30510">

  <xs:element name="Contact" type="tns:ContactType" />

- <xs:simpleType name="ContactType">

- <xs:restriction base="xs:string">

  <xs:enumeration value="Mobiles" />

  <xs:enumeration value="Home" />

  <xs:enumeration value="Business" />

  </xs:restriction>

  </xs:simpleType>

  </xs:schema>

Let us know if your service descriptions are in line with this sample.

Thanks.

Jul 8, 2008 at 10:16 AM
When I generate the proxy using svcutil I have one customer class defined with the correct serializer. I've diffed the two proxies generated and there is a big difference....

WSSF generated proxy (beginning of the file)

namespace AdventureWorksService.Client.Proxy1
{
    using System.Runtime.Serialization;
    using System;

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.CollectionDataContractAttribute(Name = "Customers", Namespace = "urn:EMA.AdvCustomerServices.DataContracts", ItemName = "Customers")]
    [System.SerializableAttribute()]
    public class Customers : System.Collections.Generic.List<AdventureWorksService.Client.Proxy1.Customer>
    {
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name = "Customer", Namespace = "urn:EMA.AdvCustomerServices.DataContracts")]
    [System.SerializableAttribute()]
    public partial class Customer : object, System.Runtime.Serialization.IExtensibleDataObject
    {

Manually generated:

[assembly: System.Runtime.Serialization.ContractNamespaceAttribute("urn:AdventureWorks.DataContracts", ClrNamespace="AdventureWorks.DataContracts")]

namespace AdventureWorks.DataContracts
{
    using System.Runtime.Serialization;
   
   
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.CollectionDataContractAttribute(Name="Customers", Namespace="urn:AdventureWorks.DataContracts", ItemName="Customers")]
    public class Customers : System.Collections.Generic.List<AdventureWorks.DataContracts.Customer>
    {
    }
   
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="Customer", Namespace="urn:AdventureWorks.DataContracts")]
    public partial class Customer : object, System.Runtime.Serialization.IExtensibleDataObject
    {
       

Jul 8, 2008 at 7:06 PM
Thanks Niall, is there any chance you could send me an email with the wsdl exposed by this service? The code is generated using a compiled unit based on the wsdl, so the error should show up overthere too.

Thanks again for your feedback.
Jul 9, 2008 at 8:35 AM
This WSDL was too long for email via Codeplex I'm afraid so here it is in its entirety.

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="CustomerService" targetNamespace="urn:EMA.AdvCustomerServices.ServiceContracts" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="urn:EMA.AdvCustomerServices.ServiceContracts" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
  <wsdl:types>
    <xsd:schema targetNamespace="urn:EMA.AdvCustomerServices.ServiceContracts/Imports">
      <xsd:import schemaLocation="http://localhost:1443/AdventureWorksService.Host/CustomerService.svc?xsd=xsd1" namespace="urn:EMA.AdvCustomerServices.ServiceContracts"/>
      <xsd:import schemaLocation="http://localhost:1443/AdventureWorksService.Host/CustomerService.svc?xsd=xsd2" namespace="urn:EMA.AdvCustomerServices.DataContracts"/>
      <xsd:import schemaLocation="http://localhost:1443/AdventureWorksService.Host/CustomerService.svc?xsd=xsd0" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="CustomersRequest">
    <wsdl:part name="Surname" element="tns:Surname"/>
  </wsdl:message>
  <wsdl:message name="CustomersResponse">
    <wsdl:part name="Customers" element="tns:Customers"/>
  </wsdl:message>
  <wsdl:message name="CustomerServiceContract_GetCustomers_CustomersFaultFault_FaultMessage">
    <wsdl:part name="detail" element="q1:CustomersFault" xmlns:q1="urn:EMA.AdvCustomerServices.DataContracts"/>
  </wsdl:message>
  <wsdl:message name="SaveCustomersRequest">
    <wsdl:part name="Customers" element="tns:Customers"/>
  </wsdl:message>
  <wsdl:message name="SaveCustomersResponse">
    <wsdl:part name="parameters" element="tns:SaveCustomersResponse"/>
  </wsdl:message>
  <wsdl:portType name="CustomerServiceContract">
    <wsdl:operation name="GetCustomers">
      <wsdl:input wsaw:Action="urn:EMA.AdvCustomerServices.ServiceContracts.CustomerServiceContract.GetCustomers" name="CustomersRequest" message="tns:CustomersRequest"/>
      <wsdl:output wsaw:Action="urn:EMA.AdvCustomerServices.ServiceContracts/CustomerServiceContract/GetCustomersResponse" name="CustomersResponse" message="tns:CustomersResponse"/>
      <wsdl:fault wsaw:Action="urn:EMA.AdvCustomerServices.ServiceContracts/CustomerServiceContract/GetCustomersCustomersFaultFault" name="CustomersFaultFault" message="tns:CustomerServiceContract_GetCustomers_CustomersFaultFault_FaultMessage"/>
    </wsdl:operation>
    <wsdl:operation name="SaveCustomers">
      <wsdl:input wsaw:Action="urn:EMA.AdvCustomerServices.ServiceContracts.CustomerServiceContract.SaveCustomers" name="SaveCustomersRequest" message="tns:SaveCustomersRequest"/>
      <wsdl:output wsaw:Action="urn:EMA.AdvCustomerServices.ServiceContracts/CustomerServiceContract/SaveCustomersResponse" name="SaveCustomersResponse" message="tns:SaveCustomersResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="Endpoint1" type="tns:CustomerServiceContract">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="GetCustomers">
      <soap:operation soapAction="urn:EMA.AdvCustomerServices.ServiceContracts.CustomerServiceContract.GetCustomers" style="document"/>
      <wsdl:input name="CustomersRequest">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="CustomersResponse">
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="CustomersFaultFault">
        <soap:fault name="CustomersFaultFault" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
    <wsdl:operation name="SaveCustomers">
      <soap:operation soapAction="urn:EMA.AdvCustomerServices.ServiceContracts.CustomerServiceContract.SaveCustomers" style="document"/>
      <wsdl:input name="SaveCustomersRequest">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="SaveCustomersResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="CustomerService">
    <wsdl:port name="Endpoint1" binding="tns:Endpoint1">
      <soap:address location="http://localhost:1443/AdventureWorksService.Host/CustomerService.svc"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
Jul 10, 2008 at 7:25 PM
The wsdl doesn't seem to have anything out of the ordinary.. Can you please take a look a this thread which may be applicable to your scenario? http://www.codeplex.com/servicefactory/Thread/View.aspx?ThreadId=31162

Let us know if it made any difference..

Thanks!
Jul 11, 2008 at 8:47 AM
Edited Jul 11, 2008 at 9:09 AM
There's my problem. I had a response class that contained two properties with IsWrapped="true". Removing one of the properties and setting IsWrapped to false then caused the proxy to be generated correctly. I'll continue on that other post.

Thanks for all the help, appreciated.