Non-primitive types

Mar 8, 2008 at 1:27 PM
Hi there,

I am new to the service model version of the WSSF but I have previously been using the Dec 06 version (the one with recipes).

Our services take data contracts as input, but for various reasons we generally return a System.Data.DataSet.

Is there a way of setting up the models to know that our service responses are datasets? At the moment I can only set up messages to contain data contracts or primitive types.

In the old version of the factory this was the same, but we could at least modify the generated code from 'System.Int32' as a return type to System.Data.DataSet. Obviously this isn't feasible if we have to do it every time the code is generated.

Any ideas? Thanks in advance.

Rich
Mar 10, 2008 at 10:52 PM
Hi Rich,

As you noticed, you can only specify Primitives or DCs. However you have a simple woraround for this and you should not need to "touch" you generated code.
Just go and open the model file with an XML Editor (from VS or simply using notepad) and look for the primitive element named foo that you wish to change its type. You should find something like this:

<primitiveMessagePart name="foo" objectExtenderContainer="" isNullable="false" isCollection="false" />
And you will change it to (assuming your type is System.Data.DataSet):

<primitiveMessagePart name="foo" objectExtenderContainer="" type="System.Data.DataSet" isNullable="false" isCollection="false" />
Save the file and you should generate the appropiate code.
Mar 11, 2008 at 10:04 AM
Thankyou very much, I will give it a try shortly!
Jun 5, 2008 at 5:51 PM
You may also try this post where you will find the required steps to update WSSF that will let you pick any kind of public types.
http://weblogs.asp.net/hernandl/archive/2008/03/28/extending-wssf-me-part-1.aspx
Jun 6, 2008 at 8:14 PM
Edited Jun 6, 2008 at 9:10 PM

Hi

I need some more help in this regard. I tried approach 1 by changing the Service contract model file. I am using "DataContract Serializer:.

Message contract files etc( on server side shows them as Data Set) where as when I generate Proxy., it generated it as a Class .

I changed following

<

primitiveMessagePart name="UserName" objectExtenderContainer="&lt;?xml version=&quot;1.0&quot;?&gt;&#xD;&#xA;&lt;ObjectExtenderContainer xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA; &lt;ObjectExtenders xsi:type=&quot;WCFPrimitiveMessagePart&quot; /&gt;&#xD;&#xA;&lt;/ObjectExtenderContainer&gt;" type="System.Int32" isNullable="false" isCollection="false" />

 

 

to

<

primitiveMessagePart name="UserName" objectExtenderContainer="&lt;?xml version=&quot;1.0&quot;?&gt;&#xD;&#xA;&lt;ObjectExtenderContainer xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA; &lt;ObjectExtenders xsi:type=&quot;WCFPrimitiveMessagePart&quot; /&gt;&#xD;&#xA;&lt;/ObjectExtenderContainer&gt;" type="System.Data.DataSet" isNullable="false" isCollection="false" />

 

Is there any tweaks I need to do so that client sees it as a data set... ?? ( schema references etc..)

Here is the proxy class file generated :
public partial class UserName : object, System.Xml.Serialization.IXmlSerializable 

 

 

{

   private

 

System.Xml.XmlNode[] nodesField;

 

 

    private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("DataSet", "http://schemas.datacontract.org/2004/07/System.Data"); 
    public System.Xml.XmlNode[] Nodes 
       {
get{return this.nodesField;}
        set{this.nodesField = value;}
        }

public void ReadXml(System.Xml.XmlReader reader)
    {
        this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);
    }
public void WriteXml(System.Xml.XmlWriter writer)
    {
        System.Runtime.Serialization.
XmlSerializableServices.WriteNodes(writer, this.Nodes);
    }

public System.Xml.Schema.XmlSchema GetSchema()
    {
        return null;
    }

 

public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas)
    {
        System.Runtime.Serialization.
XmlSerializableServices.AddDefaultSchema(schemas, typeName);
        return typeName;
    }

 

 

}

 

 

 

 

 

Jun 9, 2008 at 4:01 PM
DataContractSerializer does not support DataSets.
Try setting the XmlSerializer in your service contract model properties and re-generate code, then re build your host and try re generating your client proxy.
Jun 9, 2008 at 8:31 PM

I tried XmlSerializer which gave the same result as datacontract serializer.

I was able to get dataset type to client( though sharing of data types with client is not preferred approch and service can not be consumed by client which does not understand datasets) by generating the Proxy file using svcutil rather than WebService Factory (proxy generator). This approch does have it's own issues..

Thank you ...

Jun 18, 2009 at 12:23 AM

Similar problem at this end...

Using the WebService Factory (proxy generator).  The generated Client code won't give me access to the schema (like you can from the host). The Service Contract model is set to "XmlSerializer".

The generated code starts off like this.  I'm obviously missing something or missed a step along the way.

 

 

 

 

 

 

 

 

 

 

 

<font size="2">

 

</font>

 

public partial class StandardBusinessDocument : object, System.Xml.Serialization. IXmlSerializable

{

<font size="2">

 

</font>

 

private System.Xml.XmlNode[ ] nodesField;<font size="2">

 

</font>

 

private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("StandardBusinessDocument", "http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader"

);<font size="2">

 

</font>

 

public System.Xml.XmlNode [ ] Nodes

{

<font size="2">

 

</font>

get { return this.nodesField; }<font size="2">

 

</font>

 

set{this.nodesField = value;}

}

<font size="2">

 

</font>

 

public void ReadXml(System.Xml.XmlReader reader)

{

<font size="2">

 

</font>

 

this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);

}

<font size="2">

etc etc etc

</font>

 

Jun 18, 2009 at 1:36 PM

Are you using DataSets or XmlDocument in your DC? If so and your design allows, try changing to typed classes and collections using DC model.

Another way may be generating the client proxy with svcutil instead of WSSF client proxy generation or usign VS service reference menu option (which basically execute svcutil with a UI).

Jun 19, 2009 at 2:09 AM
Thanks.. Yes, I'm using "XMLDocument".. I'll try using the svcutil... and let you know how I get on... Thanks again.. Derek.


From: hernandelahitte [mailto:notifications@codeplex.com]
Sent: Friday, 19 June 2009 12:37 a.m.
To: Derek Elliott
Subject: Re: Non-primitive types [servicefactory:23616]

From: hernandelahitte

Are you using DataSets or XmlDocument in your DC? If so and your design allows, try changing to typed classes and collections using DC model.

Another way may be generating the client proxy with svcutil instead of WSSF client proxy generation or usign VS service reference menu option (which basically execute svcutil with a UI).


This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal
Jun 19, 2009 at 2:58 AM

Yes... thank you sooo much, Can I ask one final  question?  The XSD I'm dealing with has tags of type "any"  to allow flexibility in the types of data the XML provides.

Visual Studio does not know what to do with these "any" tags. Do you know any way around this?  This is an example of what I mean:

  <xs:complexType name="StandardBusinessDocument">

    <xs:sequence>

      <xs:element ref="StandardBusinessDocumentHeader"minOccurs="0"/>

      <xs:element ref="eanucc:message" minOccurs="0" />

      <!--<xs:any namespace="##other" processContents="lax"/>-->

    </xs:sequence>

</xs:complexType>

 

 

 

 

 

 

 

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font><font size="2" color="#0000ff">

 

</font>

 

    

Jun 19, 2009 at 12:36 PM

Here you can find teh types supported by the DC serializer: http://msdn.microsoft.com/en-us/library/ms731923.aspx

And some further explanations about WCF serialization: http://blogs.msdn.com/sowmy/archive/2006/02/22/536747.aspx

Jun 21, 2009 at 9:53 PM

Thank you very much for all your help.. you are obviously a resourceful & talented Developer.