0
votes

We have an xsd schema that outlines all the possible data elements in our system, some are simple type elements and some are complex types. We gave this schema to another developer who will try to write up a web service using SOAP. The xsd in a dumb down sample looks like this.

<xs:element name="Element1"> .... </xs:element>
<xs:element name="Element2"> .... </xs:element>
<xs:element name="Element3"> .... </xs:element>
<xs:element name="Element4"> .... </xs:element>

I plan to send our data to him by calling his WebService method. Due to the type of message generated from my system, I will have two type of messages. The first one contains Element1 and Element4 only while the second type may contains Element3, Element4 and Element1. So what are the choice does he have here?

  1. Does he have to create two separate web services and I'll consume them accordingly?
  2. Create one web service and I'll consume that one web service for both of my message types.

In the second opotion, does it generate any schema validation error? if so is there a way to get around it? can I send him a custom SOAP header to indicates the message type I send so he can validates it against specific xsd elements?

I'm relatively new to WebService so if I misunderstood the the basic mechanism of SOAP, XSD and WebService please feel free to point them out or correct any of my above assumptions.

1

1 Answers

0
votes

I think that he could make just one webservice.

I'm not very aquainted to XSD as well, but as far as I know, there is a minOccurs property that would make this work with just one webservice. For instance:

<!--The syntax may be incorrect-->
<xsd:complexType name="yourtype">
    <xsd:sequence>
        <xsd:element name="Element1" minOccurs="1" maxOccurs="1" .../>
        <xsd:element name="Element2" minOccurs="0" maxOccurs="1" ..../>            
        <xsd:element name="Element3" minOccurs="1" maxOccurs="1" ..../>
        <xsd:element name="Element4" minOccurs="1" maxOccurs="1" ..../>
    </xsd:sequence>
</xsd:complexType>

Look at the minOccurs="0", it means that the Element2 can be ommited by the other programmer. If you want some element to repeat 0 or N times, you can put maxOccurs="unbounded".