Ask a Question related to ASP.NET Web Services, Design and Development.
-
Brad Quinn #1
Adding an XmlNode parameter to the HelloWorld WebMethod
I've added an XmlNode as a parameter to the HelloWorld WebMethod. The
automaticall generated WSDL would leave one to believe that any well-formed
XML is valid.
But let's say that you expected that node to conform to some schema. How do
you get the WSDL to convey that fact. Is there a way to "hack" the WSDL?
Brad Quinn Guest
-
WebMethod signature which takes SortedList as parameter??
SortedList is a .NET class and shouldn't be used as a parameter to a Webmethod. I just posted earlier today discussing why things like this aren't... -
Adding a new WebMethod , what about old client?
If I add a new webMethod in my WebService, does this web service will continue to work fine with older client? Tks -
WebMethod + MaxOccurs for input parameter; possible?
Good afternoon everyone, I have a WebMethod function (VB .NET) that receive a parameter (Order #). I would like to be able to change my function... -
[WebMethod] passing, receving XmlNode Without a Namespace
Hi all, For some reasons I sometimes use the following interface for xml passing: public XmlNode getSomeOutputXml(XmlNode someInputXml) { }... -
DataTable parameter of a WebMethod?
DataTable is not serializable, you have to put them in a dataset. DataTable object to it. I visit the .asmx can't pass in a... -
Lucien #2
Re: Adding an XmlNode parameter to the HelloWorld WebMethod
Any well-formed XML *is* valid since you defined XmlNode as the schema so
that's
what you get in the WSDL. If you need a more 'restrictive' schema define a
class.
"Brad Quinn" <brad_quinn@yahoo.com> wrote in message
news:uX5hQz5VDHA.624@TK2MSFTNGP10.phx.gbl...well-formed> I've added an XmlNode as a parameter to the HelloWorld WebMethod. The
> automaticall generated WSDL would leave one to believe that anydo> XML is valid.
>
> But let's say that you expected that node to conform to some schema. How> you get the WSDL to convey that fact. Is there a way to "hack" the WSDL?
>
>
Lucien Guest
-
Brad Quinn #3
Re: Adding an XmlNode parameter to the HelloWorld WebMethod
One problem with this is that a schema is more rigorous than a class. For
instance;
Lets say I generate a class from a schema using xsd. I now use this class
as a parameter to my web service. The wsdl that is generated will allow XML
that the original schema would have rejected. This is easy to see when
using <xs:choice ...> with minOccurs and maxOccurs.
Is there a way to tweak (or outright specify completely) the wsdl of a
WebService?
"Lucien" <Xlucienen [email]X@hotmail.com[/email]> wrote in message
news:3f299f01$1@news.microsoft.com...How> Any well-formed XML *is* valid since you defined XmlNode as the schema so
> that's
> what you get in the WSDL. If you need a more 'restrictive' schema define a
> class.
>
> "Brad Quinn" <brad_quinn@yahoo.com> wrote in message
> news:uX5hQz5VDHA.624@TK2MSFTNGP10.phx.gbl...> well-formed> > I've added an XmlNode as a parameter to the HelloWorld WebMethod. The
> > automaticall generated WSDL would leave one to believe that any> > XML is valid.
> >
> > But let's say that you expected that node to conform to some schema.WSDL?> do> > you get the WSDL to convey that fact. Is there a way to "hack" the>> >
> >
>
Brad Quinn Guest
-
Lucien #4
Re: Adding an XmlNode parameter to the HelloWorld WebMethod
You can express a choice in a class. Use attributes like this:
[System.Xml.Serialization.XmlElementAttribute("Clas s1", typeof(Class1))]
[System.Xml.Serialization.XmlElementAttribute("Clas s2", typeof(Class2))]
public object myChoiceClass ...
If there would be a schema definition that you couldn't express in a class
you could create the proxy manually by using the WSDL.exe tool. However most
implementations don't do a full WSDL schema check and it would only fail if
(de)serialize fails. So you'd have to add the check programmatically if you
needed to enforce special constraints.
"Brad Quinn" <brad_quinn@yahoo.com> wrote in message
news:%23fNsPvCWDHA.2212@TK2MSFTNGP12.phx.gbl...XML> One problem with this is that a schema is more rigorous than a class. For
> instance;
>
> Lets say I generate a class from a schema using xsd. I now use this class
> as a parameter to my web service. The wsdl that is generated will allowso> that the original schema would have rejected. This is easy to see when
> using <xs:choice ...> with minOccurs and maxOccurs.
>
> Is there a way to tweak (or outright specify completely) the wsdl of a
> WebService?
>
> "Lucien" <Xlucienen [email]X@hotmail.com[/email]> wrote in message
> news:3f299f01$1@news.microsoft.com...> > Any well-formed XML *is* valid since you defined XmlNode as the schemaa> > that's
> > what you get in the WSDL. If you need a more 'restrictive' schema define> How> > class.
> >
> > "Brad Quinn" <brad_quinn@yahoo.com> wrote in message
> > news:uX5hQz5VDHA.624@TK2MSFTNGP10.phx.gbl...> > well-formed> > > I've added an XmlNode as a parameter to the HelloWorld WebMethod. The
> > > automaticall generated WSDL would leave one to believe that any> > > XML is valid.
> > >
> > > But let's say that you expected that node to conform to some schema.> WSDL?> > do> > > you get the WSDL to convey that fact. Is there a way to "hack" the>> >> > >
> > >
> >
>
Lucien Guest
-
Lucien #5
Re: Adding an XmlNode parameter to the HelloWorld WebMethod
The WSDL is not used for schema validation unless you add this yourself (as
a SoapExtension for instance).
You could create a XSD schema and use that for schema validation (or save a
WSDL file and modify it).
"Brad Quinn" <brad_quinn@yahoo.com> wrote in message
news:ujoa0zEWDHA.384@TK2MSFTNGP12.phx.gbl.../>> I'm planning on doing schema validation in a SoapExtension.
>
> I want the consumer of my WebService to be forewarned.
>
> Lets say this is the schema fragment that I'm going to validate with;
>
> <xs:complexType name="Class1"> ...
> <xs:complexType name="Class2"> ...
>
> <xs:choice minOccurs="1" maxOccurs="2">
> <xs:element name="Class1" type="Class1" minOccurs="0" maxOccurs="1"/>> <xs:element name="Class2" type="Class2" minOccurs="0" maxOccurs="1"typeof(Class1))]> </xs:choice>
>
> The corresponding field in C# would look like this;
>
> [System.Xml.Serialization.XmlElementAttribute("Clas s1",typeof(Class2))]> [System.Xml.Serialization.XmlElementAttribute("Clas s2",type="s1:Class1"> public object [] myChoiceClass;
>
> But the generated WSDL looks like this, which isn't quite right;
>
> <s:choice minOccurs="0" maxOccurs="unbounded">
> <s:element minOccurs="0" maxOccurs="1" name="Class1"type="s1:Class2"> />
> <s:element minOccurs="0" maxOccurs="1" name="Class2"class> />
> </s:choice>
>
> It looks pretty close, but looks can be deceiving. I could easily modify
> the schema so that the WSDL wouldn't look like it was mostly correct.
>
> "Lucien" <Xlucienen [email]X@hotmail.com[/email]> wrote in message
> news:3f2a8d1d$1@news.microsoft.com...> > You can express a choice in a class. Use attributes like this:
> >
> > [System.Xml.Serialization.XmlElementAttribute("Clas s1", typeof(Class1))]
> > [System.Xml.Serialization.XmlElementAttribute("Clas s2", typeof(Class2))]
> > public object myChoiceClass ...
> > If there would be a schema definition that you couldn't express in a> most> > you could create the proxy manually by using the WSDL.exe tool. However> if> > implementations don't do a full WSDL schema check and it would only fail> you> > (de)serialize fails. So you'd have to add the check programmatically if>> > needed to enforce special constraints.
> >
> <snip/>
>
>
Lucien Guest



Reply With Quote

