What Should dataset do in WCF?

Source: Internet
Author: User

Http://java.sun.com/webservices/reference/tutorials/wsit/doc/DataBinding.htmlData (contracts)

This chapter describes guidelines:

    • Designing a XML Schema exposed by a Web service starting from Java
    • Consuming a WCF Service generated WSDL/XML Schema when designing a Java client or Java Web Service
    • Developing a Microsoft WCF Client

A wsit client/service uses jaxb 2.0 for XML serialization, generating XML schemas from Java classes and generating Java classes from XML schemas. a WCF client/service uses either Xmlserializer Or Datacontractserializer For like tasks. jaxb 2.0 and the wcf xml serialization mechanic ISMs differ in two fundamental ways. First, jaxb 2.0 supports all of XML Schema.. Net's Datacontractserializer And Xmlserializer Support different XML Schema sets. Second, WCF's Xmlserializer / Datacontractserializer And jaxb 2.0 differ in their mapping of programming language datatypes to XML Schema constructs. as a result, a XML Schema generated from a programming language on one platform and consumed on another platform may result in less than developer-friendly bindings. this chapter discusses some of the common databinding differences between the two systems and recommends ways to address them.

Forum 2:
Http://forums.java.net/jive/thread.jspa? Threadid = 23398

Summary: there are multiple threads related to dataset in these forums. This is an area that needs some guidelines in general.

First, consider how a dataset is mapped.

 
[Datacontract]Public ClassFoo {[datamember]PublicDataset Ds ;}

Will map

[Code]
<Xs: complextype name = "foo">
<Xs: sequence>
<Xs: Element minoccurs = "0" name = "ds" nillable = "true">
<Xs: complextype>
<Xs: annotation>
<Xs: appinfo>
<Actualtype name = "dataset" namespace = "http://schemas.datacontract.org/2004/07/System.Data" xmlns = "http://schemas.microsoft.com/2003/10/Serialization/"/>
</Xs: appinfo>
</Xs: annotation>
<Xs: sequence>
<Xs: Element ref = "XS: schema"/>
<Xs: Any/>
</Xs: sequence>
</Xs: complextype>
</Xs: Element>
</Xs: sequence>
</Xs: complextype>
<Xs: element name = "foo" nillable = "true" type = "TNS: foo"/>

[/Code]

Notice that <element ref = "XS: schema"/>. This will cause wsimport to fail. There is an issue already logged against this. https://jaxp.dev.java.net/issues/show_bug.cgi? Id = 14. The generated schema allows the schema to be deferred until runtime; since a dataset can be filled at runtime, there is no way of knowing what the schema is at design time.

One way to avoid to this to pass a stronugly Typed Dataset. For example,

 
[Datacontract]Public ClassFoo {[datamember]PublicBooksdataset BDS ;}Public ClassBooksdataset: DataSet {...}

This will generate a different schema. Notice that <element ref = "XS: schema"/> is no longer generated.

<Xs: complextype name = "foo"> <Xs: sequence> <Xs: Element minoccurs = "0" name = "BDS" nillable = "true" type = "TNS: booksdataset "/> </Xs: sequence> </Xs: complextype> <Xs: element name =" foo "nillable =" true "type =" TNS: foo "/> <Xs: complextype name =" booksdataset "> <Xs: sequence> <Xs: Any namespace =" "/> </Xs: sequence> </Xs: complextype> <Xs: element name = "booksdataset" nillable = "true" type = "TNS: booksdataset"/>

The above shoshould be consumable by wsimport. However, the object model is driven by the above schema. So one wocould get java. Lang. Object for Xs: Any.

In short, datasets work well in MS specific environment but not cross platform.
Other suggestions on the Forum and/or elsewhere indicate that other types cocould be used instead of a stronugly typed dataset-e.g. arrays, xmlnode, or xmldatadocument.

This is an area where we cocould use guidlines. Please post your feedback on this thread and I will induplicate ate it into a future version of the datacontracts chapter
(Go to http://weblogs.java.net/blog/sekhar/archive/2007/02/jaxb_and_wcf_da_2.html; follow the link to data contracts chapter ).

Message was edited by: sekhar

----------------------------------------
The suggestion was not to expose dataset to from the. NET service. Instead, map dataset to another. Net Type and expose that datatype. For e. g In Your. net service,
1. Use a stronugly Typed Dataset instead of dataset (above example ).
2. Map dataset to a jarged array (e.g. object [] [])
3. Map dataset to a system. xml. xmlnode. For e.g.

 
Dataset Ds; //... fill in dataset xmlnode =NewXmldatadocument (DS );

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.