Generating a SOAP message from WSDL without creating a proxy class.

I am writing a program that reads the WDSL document and generates a SOAP message in C#. I don’t want to create a proxy class from the WSDL document, I need the program to understand the WSDL document and be able to generate a SOAP message. I am working on generating the SOAP body from the types part of the WSDL, using the ServiceDescription class. My problem now is thatI can’t reach the elements contained within other elements in the schema, and work on them. I’m using

XmlSchemaObjectTable XmlSchema.Element to access the elements, but when I use that and count the elements for example, it doesn’t count the element contained inside the other elements and I don’t know how to access them.Below is an example:

<wsdl:types>

<s:schemaelementFormDefault="qualified"targetNamespace="http://www.webserviceX.NET/">

<s:elementname="GetQuote">

<s:complexType>

<s:sequence>

<s:elementminOccurs="0"maxOccurs="1"name="symbol"type="s:string"/>

</s:sequence>

</s:complexType>

</s:element>

<s:elementname="GetQuoteResponse">

<s:complexType>

<s:sequence>

<s:elementminOccurs="0"maxOccurs="1"name="GetQuoteResult"type="s:string"/>

</s:sequence>

</s:complexType>

</s:element>

<s:elementname="string"nillable="true"type="s:string"/>

</s:schema>

</wsdl:types>

When I count the elements in the schema the answer is 3, GetQuote, GetQuoteResponse and string, and I don’t know what methods or classes to use to access the other ones. Can anybody help me with this. If my question is not clear enough I can try to explain it better.

Best regards,

Signy

[11468 byte] By [signy] at [2007-12-16]
# 1
Hi there! Check out the documentation for the XmlSchemaElement class. It has several properties that you can use to look at the element's type and from there get to the sequence "particle" and then the contained element. You can also see an example of how to do this by looking at the file DefaultWsdlHelpGenerator.aspx, which should be in the same directory as your machine.config file.
Hope this helps..
Alex DeJarnatt
AlexDeJarnatt at 2007-9-9 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...

.NET Development

Site Classified