DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 18 Jul 2007 09:29:33 -0700,    posted on: microsoft.public.dotnet.framework.aspnet.webservices        back       

Thread Index
  1    Jeremy
          2    John Saunders [MVP] john.saunders at trizetto.com
                 3    Jeremy
                        4    John Saunders [MVP] john.saunders at trizetto.com


IXmlSerializable.GetSchema creates mutiple schema elements in my wsdl   
I've built a class that uses the IXmlSerializable interface to do custom 
serialization.  I"ve then used the IXmlSerializable.GetSchema() method to 
output the schema of my class to the wsdl in my web service.  The problem is 
that the schema of my class appears in a seperate schema element in the 
wsdl.  It needs to be in the main schema element so that an application can 
consume the web service properly, because I've found that at least with .net 
apps, they only consume the first schema element.  How can I get only one 
schema element in the wsdl?

I've included my class and the wsdl snippets below:

My Class:
public class AnyTextData2 : AnyTextData, 
System.Xml.Serialization.IXmlSerializable
{
    public AnyTextData2()
    {

    }

    System.Xml.Schema.XmlSchema 
System.Xml.Serialization.IXmlSerializable.GetSchema()
    {
        /*
        <s:complexType name="AnyTextData2">
            <s:simpleContent>
                <s:extension base="s:string">
                    <s:attribute name="Attribute" type="s:string" />
                </s:extension>
            </s:simpleContent>
        </s:complexType>
        */

        System.Xml.Schema.XmlSchema pSchema = new 
System.Xml.Schema.XmlSchema();
        pSchema.ElementFormDefault = 
System.Xml.Schema.XmlSchemaForm.Qualified;
        pSchema.Id = "0"; //Seems an id is mandatory

        //<s:complexType name="CData">
        System.Xml.Schema.XmlSchemaComplexType pComplexType = new 
System.Xml.Schema.XmlSchemaComplexType();
        pComplexType.Name = "AnyTextData2";

        //<xs:simpleContent>
        System.Xml.Schema.XmlSchemaSimpleContent pSimpleContent = new 
System.Xml.Schema.XmlSchemaSimpleContent();

        //<s:extension base="s:string">
        System.Xml.Schema.XmlSchemaSimpleContentExtension pExtension = new 
System.Xml.Schema.XmlSchemaSimpleContentExtension();
        pExtension.BaseTypeName = new 
System.Xml.XmlQualifiedName("string");//"s:string"

        //<s:attribute name="Attribute" type="s:string" />
        System.Xml.Schema.XmlSchemaAttribute pAttribute = new 
System.Xml.Schema.XmlSchemaAttribute();
        pAttribute.Name = "Attribute";
        pAttribute.SchemaTypeName = new 
System.Xml.XmlQualifiedName("string");//"s:string"
        pExtension.Attributes.Add(pAttribute);

        pSimpleContent.Content = pExtension;
        pComplexType.ContentModel = pSimpleContent;

        pSchema.Items.Add(pComplexType);

        return pSchema;

    }

    void 
System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader 
reader)
    {

    }

    void 
System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter 
writer)
    {
        writer.WriteAttributeString("Attribute", this.Attribute);
        writer.WriteCData(this.Text.Data);
    }

}

WSDL snippets:
 <?xml version="1.0" encoding="utf-8" ?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
xmlns:tns="http://tempuri.org/" xmlns:s1="http://tempuri2.org/" 
xmlns:s="http://www.w3.org/2001/XMLSchema" 
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
targetNamespace="http://tempuri.org/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
 <wsdl:types>
  <s:schema elementFormDefault="qualified" 
targetNamespace="http://tempuri.org/">
  ...
  </s:schema>
  <s:schema elementFormDefault="qualified" 
targetNamespace="http://tempuri2.org/" id="0">
   <s:complexType name="AnyTextData2">
    <s:simpleContent>
     <s:extension base="string">
      <s:attribute name="Attribute" type="string" />
       </s:extension>
    </s:simpleContent>
   </s:complexType>
  </s:schema>
 </wsdl:types>
</wsdl:definitions>
Date:Wed, 18 Jul 2007 09:29:33 -0700   Author:  

Re: IXmlSerializable.GetSchema creates mutiple schema elements in my wsdl   
"Jeremy"  wrote in message 
news:ejg8CkVyHHA.5204@TK2MSFTNGP03.phx.gbl...

> I've built a class that uses the IXmlSerializable interface to do custom 
> serialization.  I"ve then used the IXmlSerializable.GetSchema() method to 
> output the schema of my class to the wsdl in my web service.  The problem 
> is that the schema of my class appears in a seperate schema element in the 
> wsdl.  It needs to be in the main schema element so that an application 
> can consume the web service properly, because I've found that at least 
> with .net apps, they only consume the first schema element.  How can I get 
> only one schema element in the wsdl?


Jeremy,

I'll try to look at this in more detail later, but for now have a comment: 
you are mistaken about .NET applications only consuming the first schema 
element. I have a production web service using four schemas. I did this by 
using wsdl:import elements outside of the <wsdl:types> element. It's 
apparently not WS-I compliant, but it works well. I intend (in my copious 
spare time) to see if I can do the equivalent by adding <schema> elements in 
the <wsdl:types> and using <xs:include> to load the "real" schemas.
-- 
John Saunders [MVP]
Date:Wed, 18 Jul 2007 13:54:53 -0400   Author:  

Re: IXmlSerializable.GetSchema creates mutiple schema elements in my wsdl   
The reason I thought it was ignoring the second schema element is because 
when I consume the web service, the method that returns the datatype 
specified in the second scheme element has a return type of XmlElement in 
the proxy class, rather than the actual data type.

"John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message 
news:esGz7SWyHHA.4184@TK2MSFTNGP06.phx.gbl...

> "Jeremy"  wrote in message 
> news:ejg8CkVyHHA.5204@TK2MSFTNGP03.phx.gbl...
>> I've built a class that uses the IXmlSerializable interface to do custom 
>> serialization.  I"ve then used the IXmlSerializable.GetSchema() method to 
>> output the schema of my class to the wsdl in my web service.  The problem 
>> is that the schema of my class appears in a seperate schema element in 
>> the wsdl.  It needs to be in the main schema element so that an 
>> application can consume the web service properly, because I've found that 
>> at least with .net apps, they only consume the first schema element.  How 
>> can I get only one schema element in the wsdl?
>
> Jeremy,
>
> I'll try to look at this in more detail later, but for now have a comment: 
> you are mistaken about .NET applications only consuming the first schema 
> element. I have a production web service using four schemas. I did this by 
> using wsdl:import elements outside of the <wsdl:types> element. It's 
> apparently not WS-I compliant, but it works well. I intend (in my copious 
> spare time) to see if I can do the equivalent by adding <schema> elements 
> in the <wsdl:types> and using <xs:include> to load the "real" schemas.
> -- 
> John Saunders [MVP]
> 
Date:Wed, 18 Jul 2007 11:59:06 -0700   Author:  

Re: IXmlSerializable.GetSchema creates mutiple schema elements in my wsdl   
"Jeremy"  wrote in message 
news:OISzn3WyHHA.3788@TK2MSFTNGP02.phx.gbl...

> The reason I thought it was ignoring the second schema element is because 
> when I consume the web service, the method that returns the datatype 
> specified in the second scheme element has a return type of XmlElement in 
> the proxy class, rather than the actual data type.


If it had been ignoring the second schema, it could not have created your 
proxy class at all.

Instead, this appears to be a problem with the type being returned from that 
method, or the way the type is specified. Can you post the signature of the 
webmethod, complete with any attributes on it?

-- 
John Saunders [MVP]
Date:Wed, 18 Jul 2007 19:35:39 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us