I was stunned, I had defined a Request schema and a Response schema to be used by a Web Service I wanted to implement in BizTalk 2004. The Request schema was straightforward, just some fields which made up a Service Request. The response would be a collection of 0 to N "Records".
I had the Response Schema defined somehere around the lines of this:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://BizTalk_Webservice_Publishing_issue.Schema2" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalk_Webservice_Publishing_issue.Schema2" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Record">
<xs:complexType>
<xs:sequence>
<xs:element name="Field1" type="xs:string" />
<xs:element name="Field2" type="xs:string" />
<xs:element name="Field3" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Looks sensible right? It compiles okay, I can make an Orchestration with a Request-Response port, everything looks fine, until the Web Service Publishing Wizard gives me:
Failed to create project http://localhost/BizTalk_Webservice_Publishing_issue_Proxy.
[Microsoft.BizTalk.WebServices.PublishingException] Failed to construct code for schema "http://BizTalk_Webservice_Publishing_issue.Schema2".
Method not found: System.String System.Xml.Serialization.XmlMapping.get_ElementName().
I didn't get it, what was wrong? After searching the internet (in which I obviously found one of Patrick's blogpost which didn't help in this case as I had no imported schema's) I began some experiments. I determined that the cause lies in the multiplicity on the Record element. It didn't matter what values I used, as soon as the schema allowed more than one Record element to be a part of the message, the Wizard failed on me.
I don't remember how I got the idea, but the solution is rather simple. It appears that the Wizard doesn't like the multiplicity on the element. So, let's put the multiplicity one level higher, around the element, like this:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://BizTalk_Webservice_Publishing_issue.Schema2" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalk_Webservice_Publishing_issue.Schema2" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Record">
<xs:complexType>
<xs:sequence>
<xs:element name="Field1" type="xs:string" />
<xs:element name="Field2" type="xs:string" />
<xs:element name="Field3" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
So after encapsulating the Record element in a Sequence on which I added the multiplicity, all was well. I don't think I fully understand why the Wizard (or XSD.exe which is running the show in the background) fails on the first version, but now I do know how to solve this.
Update: fixed the formatting of the XML Schema's for readability.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
BizTalk 2004