Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BizTalk Web Reference - generated XSD has "lost" information from WSDL

I am using BizTalk 2006 R2 to generate a web reference from a WSDL file.

Comparing the generated XSD to the WSDL, it is apparent that a lot of information has been lost.

Consider the following extract from the WSDL:

<s:element form="unqualified" minOccurs="0" maxOccurs="4" name="Applicant">
  <s:complexType>
    <s:sequence>
      <s:element form="unqualified" minOccurs="1" maxOccurs="1" name="ApplicantIdentifier">
        <s:simpleType>
          <s:restriction base="s:string" />
        </s:simpleType>
      </s:element>
      <s:element form="unqualified" minOccurs="0" maxOccurs="1" name="Name">
        <s:complexType>
          <s:sequence>
            <s:element form="unqualified" minOccurs="0" maxOccurs="1" name="Title">
              <s:simpleType>
                <s:restriction base="s:string">
                  <s:maxLength value="10" />
                </s:restriction>
              </s:simpleType>
            </s:element>
            <s:element form="unqualified" minOccurs="0" maxOccurs="1" name="Forename">
              <s:simpleType>
                <s:restriction base="s:string">
                  <s:pattern value="[0-9A-Za-z \-]*" />
                  <s:maxLength value="15" />
                  <s:minLength value="1" />
                </s:restriction>
              </s:simpleType>
            </s:element>
            <!-- more -->
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:sequence>
  </s:complexType>
</s:element>

The equivalent XSD which BizTalk has generated is:

<xs:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="Applicant">
  <xs:complexType>
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="ApplicantIdentifier" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="Name">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="Title" type="xs:string" />
            <xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="Forename" type="xs:string" />
            <!-- more -->
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>

So, the XSD has lost the restriction patterns and has set its own values for minOccurs and maxOccurs.

I need to map from another source to the XSD and I wish to trap data that does not conform to the WSDL at that stage.

Does anyone know why BizTalk has not preserved the restrictions in the XSD; or how I can generate non-lossy XSD?

like image 560
NickBeaugié Avatar asked Jun 07 '10 09:06

NickBeaugié


1 Answers

Unless you're doing schema validation in a BizTalk pipeline, restrictions and maxoccurs > 1 aren't actually going to do anything - they're not used by BizTalk at runtime. I'm guessing this is the reason why the web reference is lossy.

I've personally never liked the 'add web reference' feature, or even the 'add adapter metadata'/WCF. If your wsdl is changing that frequently that manually copying the type definitions into an xsd file is too much work:

a) look at building a simple console app to retrieve the wsdl, extract the type(s) and update the xsd file (kick it off from the External Tools menu in VS), and

b) work out what's going wrong with your development process that requires service contract changes that often!

like image 185
Sam Avatar answered Oct 02 '22 07:10

Sam