by matt
3. January 2008 21:35
Recently, I was trying to go back and complete my blog about using web services in BizTalk without using orchestrations. As is quite normal for me, my notes were generally bereft of any real detail and I could not for the life of me figure out how I managed to get Visual Studio to generate an XSD (and thus a schema to use in BizTalk). It was simply written and 'Visual Studio will create the schema for me'; all very good and well but it was not creating one for me now.
In my attempts to try recreating the scenario whereby I could create the XSD from a web reference, I created a simple web service and added a web reference to an empty BizTalk project in Visual Studio. I then started off looking through my notes to try and get an XSD out of the web reference. Early on, a lot of my scribbled notes were about using
xsd.exe,
wsdl.exe and
csc.exe. These proved to be unfruitful in terms of actually generating a XSD file.
After a fair amount of head scratching I noticed something a little different with the web service that I had originally used and the simple test harness that I was using to try to replicate the creation of the XSD. In my test harness, I was attempting to call a web service with a web method that accepted a string and an integer as it parameters. In contrast, in my previous attempt, I had only one parameter that was a non-primitive type. I noticed that the created XSD that I already had was a definition of the non-primitive type, rather than a definition of the entire SOAP method. With that in mind, I updated my test harness web service and added a class to create a non-primitive for the parameter. That was the ticket and when I refreshed the web reference, Visual Studio created an XSD file describing the non-primitive.
I then decided to take things a little further and added another non-primitive type to my web service that was employed by a new web method. My hope was that this would create an additional XSD file for the new non-primitive. Alas it didn’t quite work as planned and it created another root node in the existing schema. I think there I will need to do some more investigation, but for the time being it allows me to continue investigating the use of web services without having to use orchestrations.
A few notes that may come in handy:
- This method only works for non-primitive types.
- The XSD files only get generate in BizTalk projects to my knowledge.
- The generated XSD only generates schemas for non-primitive types that are used within the services public methods that are both public and serializable.
Relevant Technologies
References: