First of all, I am new to C# and Web services in general. I am trying to read a WSDL file and from that, generate the code required for our industrial control device to make calls to this Web service. The code is in our own scripting language.
So what I need to know is how can I read the WSDL and, generate the generic SOAP message for each method defined there?
I have code that already reads the WSDL and I can get the host, port and that sort of thing, but the problem with the current way I am doing things is that I can find the MessagePart that I want, and the element attribute of that part, but I can not figure out how to get the complex datatype for that element.
The way I am doing it may not be the best way. I have even thought of taking a huge step back and simply parsing the WSDL as an XML file myself...yuk!
Any help on how I can best accomplish this task would be greatly appreciated.
I'm not 100% sure about what you're trying to do, or how you're trying to do it, so let me start by making a bunch of assumptions.
- Your client is written in a proprietary scripting language.
- You're using C# and the .NET Framework to connect your scripting language to SOAP.
- You're trying to obtain a WSDL file and dynamically invoke the service at runtime
- You're using the system.web.services.description class library to interpret the WSDL file
Just a warning: I'm not all that familiar with the .NET Framework, so I'm just guessing here.
So using system.web.services.description you've managed to get as far as getting the element qname from the MessagePart.
So now you need to find the XSD definition of the element. The element definition may be within the <types> element, or it may be defined in an imported file, such as a schema. The qname namespace prefix will tell you where to find the definition. If the element is defined in the <types> element, you need to use the types class to go find the types.schemas property.
Now here is where it gets tricky. Now you have to switch to the System.Xml.Schema class library. This class library lets you parse a schema. Find the Element class followed by the ComplexType class and I think you'll be all set.
Dig Deeper on Service-oriented architecture (SOA)
Related Q&A from Anne Thomas Manes
Anne Thomas Manes explains the differences between open source clients and open source implementations. Continue Reading
Anne Thomas Manes discusses the best way to go about creating an enterprise data dictionary and why the systems works well. Continue Reading
Anne Thomas Manes explains the difference between 'hard' real time and 'live' real time systems. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.