soa-model icon indicating copy to clipboard operation
soa-model copied to clipboard

Problem creating request with more when one item.

Open kkirakosyan opened this issue 9 years ago • 3 comments

I am trying the CreateSOAPRequest example that I got from downloads part on 1.5.4 version of soa-model-core. So I have problems related multiple items of same type: for example

formParams.put("xpath:/create/article[1]/price[1]/amount", "10.00");

we have multiple articles and multiple prices. After running example I got this result

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
  <s11:Body>
    <ns1:create xmlns:ns1='http://predic8.com/wsdl/material/ArticleService/1/'>
      <article>
<!-- This element is required and should be filled. -->
        <ns2:name xmlns:ns2='http://predic8.com/material/1/' />
<!-- This element is required and should be filled. -->
        <ns2:description xmlns:ns2='http://predic8.com/material/1/' />
        <ns2:price xmlns:ns2='http://predic8.com/material/1/'>
<!-- This element is required and should be filled. -->
          <ns3:amount xmlns:ns3='http://predic8.com/common/1/' />
          <ns3:currency xmlns:ns3='http://predic8.com/common/1/'></ns3:currency>
        </ns2:price>
        <ns2:id xmlns:ns2='http://predic8.com/material/1/'></ns2:id>
      </article>
    </ns1:create>
  </s11:Body>
</s11:Envelope>

but it should be

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
  <s11:Body>
    <ns1:create xmlns:ns1='http://predic8.com/wsdl/material/ArticleService/1/'>
      <article>
        <name xmlns:ns2='http://predic8.com/material/1/'>foo2</name>
        <description xmlns:ns2='http://predic8.com/material/1/'>bar2</description>
        <price xmlns:ns2='http://predic8.com/material/1/'>
          <amount xmlns:ns3='http://predic8.com/common/1/'>10.00</amount>
          <currency xmlns:ns3='http://predic8.com/common/1/'>EUR</currency>
        </price>
        <id xmlns:ns2='http://predic8.com/material/1/'>2</id>
      </article>
      <article>
       <name xmlns:ns2='http://predic8.com/material/1/'>foo1</name>
        <description xmlns:ns2='http://predic8.com/material/1/'>bar1</description>
        <price xmlns:ns2='http://predic8.com/material/1/'>
          <amount xmlns:ns3='http://predic8.com/common/1/'>20.00</amount>
          <currency xmlns:ns3='http://predic8.com/common/1/'>USD</currency>
        </price>
        <id xmlns:ns2='http://predic8.com/material/1/'>1</id>
      </article>
    </ns1:create>
  </s11:Body>
</s11:Envelope>

I didn't change anything in source code.

kkirakosyan avatar Aug 27 '15 14:08 kkirakosyan

I need to push that issue. We have tracked down the reason and can give an example WSDL with following ComplexType, where this Problem occurs for us

<xsd:simpleType name="mediumBlob">
    <xsd:restriction base="xsd:base64Binary">
        <xsd:maxLength value="16384" />
    </xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="Identity">
    <xsd:sequence>
        <xsd:element name="data_A" type="xsd:base64Binary" minOccurs="0" maxOccurs="10"/>
        <xsd:element name="data_B" type="tns:mediumBlob" minOccurs="0" maxOccurs="10"/>
        <xsd:element name="data_C" type="tns:mediumBlob" minOccurs="0" maxOccurs="10"/>
    </xsd:sequence>
</xsd:complexType>

In our code we set all elements and they data into a String HashMap to put them into the Operation later-on:

HashMap<String, String> data = new HashMap<>();
data.put("xpath:/MyOperation/id/data_A[1]", "###");
data.put("xpath:/MyOperation/id/data_A[2]", "XXX");
data.put("xpath:/MyOperation/id/data_B[1]", "###");
data.put("xpath:/MyOperation/id/data_B[2]", "XXX");
data.put("xpath:/MyOperation/id/data_C", "###");
msg_MyOperation.addData(data);

This generates following Request content:

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
    <s11:Body>
        <ns1:MyOperation xmlns:ns1='https://www.MyNameSpace.tld/abc'>
            <id>
                <data_A>###</data_A>
                <data_A>XXX</data_A>
                <data_B></data_B>
                <data_C>###</data_C>
            </id>
        </ns1:MyOperation>
    </s11:Body>
</s11:Envelope>

But expected was:

                <data_A>###</data_A>
                <data_A>XXX</data_A>
                <data_B>###</data_B>
                <data_B>XXX</data_B>
                <data_C>###</data_C>

  • both <data_A> are added because of type="xsd:base64Binary"
  • <data_C> is no direct type="xsd:base64Binary" and added, because only one Occurence is added
  • <data_B> is like <data_C> but not added at all, only one empty <data_B> because the fault is partly located in the Groovy-Scripts:

While generating the request, during the creation of BuildInSchemaType-Objects, matching Xpath-Elements are identified by a Regular Expression. During that creation of SimpleType-Objekts only 1-to-1 matches are searched.

<data_B> is no BuildInSchemaType SimpleType and finally it Fails

Hopefully that's correct ;-)

psytester avatar Aug 04 '16 11:08 psytester

Hi,

thanks for your valueable description of the bug. It will take some time till we will fix that is SOA Model. Feel free to create a pull-request yourself if you want to. The code fort he RequestCreator is at the file:

https://github.com/membrane/soa-model/blob/master/core/src/main/groovy/com/predic8/wstool/creator/RequestCreator.groovy

Cheers,

Thomas

Am 04.08.16, 13:45 schrieb "psytester" [email protected]:

I need to push that issue. We have tracked down the reason and can give an example WSDL with following ComplexType, where this Problem occurs for us <xsd:simpleType name="mediumBlob">     <xsd:restriction base="xsd:base64Binary">         <xsd:maxLength value="16384" />     /xsd:restriction /xsd:simpleType

<xsd:complexType name="Identity">     xsd:sequence         <xsd:element name="data_A" type="xsd:base64Binary" minOccurs="0" maxOccurs="10"/>         <xsd:element name="data_B" type="tns:mediumBlob" minOccurs="0" maxOccurs="10"/>         <xsd:element name="data_C" type="tns:mediumBlob" minOccurs="0" maxOccurs="10"/>     /xsd:sequence /xsd:complexType In our code we set all elements and they data into a String HashMap to put them into the Operation later-on: HashMap<String, String> data = new HashMap<>(); data.put("xpath:/MyOperation/id/data_A[1]", "###"); data.put("xpath:/MyOperation/id/data_A[2]", "XXX"); data.put("xpath:/MyOperation/id/data_B[1]", "###"); data.put("xpath:/MyOperation/id/data_B[2]", "XXX"); data.put("xpath:/MyOperation/id/data_C", "###"); msg_MyOperation.addData(data); This generates following Request content: <s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>     s11:Body         <ns1:MyOperation xmlns:ns1='https://www.MyNameSpace.tld/abc'>                             <data_A>###</data_A>                 <data_A>XXX</data_A>                 <data_B></data_B>                 <data_C>###</data_C>                     /ns1:MyOperation     /s11:Body /s11:Envelope But expected was:                 <data_A>###</data_A>                 <data_A>XXX</data_A>                 <data_B>###</data_B>                 <data_B>XXX</data_B>                 <data_C>###</data_C>

both <data_A> are added because of type="xsd:base64Binary" <data_C> is no direct type="xsd:base64Binary" and added, because only one Occurence is added <data_B> is like <data_C> but not added at all, only one empty <data_B> because the fault is partly located in the Groovy-Scripts: While generating the request, during the creation of BuildInSchemaType-Objects, matching Xpath-Elements are identified by a Regular Expression. During that creation of SimpleType-Objekts only 1-to-1 matches are searched.

<data_B> is no BuildInSchemaType SimpleType and finally it Fails

Hopefully that's correct ;-)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

keshavarzi avatar Aug 04 '16 20:08 keshavarzi

CreateSOAPRequest run result not correct (there are no data in element & ): soa-model version is

<dependency>
            <groupId>com.predic8</groupId>
            <artifactId>soa-model-core</artifactId>
            <version>1.6.0</version>
</dependency>

result is:

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
  <s11:Body>
    <ns1:create xmlns:ns1='http://predic8.com/wsdl/material/ArticleService/1/'>
      <article>
        <ns2:name xmlns:ns2='http://predic8.com/material/1/'>foo2</ns2:name>
        <ns2:description xmlns:ns2='http://predic8.com/material/1/'>bar2</ns2:description>
        <ns2:price xmlns:ns2='http://predic8.com/material/1/'>
<!-- This element is required and should be filled. -->
          <ns3:amount xmlns:ns3='http://predic8.com/common/1/' />
          <ns3:currency xmlns:ns3='http://predic8.com/common/1/'></ns3:currency>
        </ns2:price>
        <ns2:id xmlns:ns2='http://predic8.com/material/1/'>2</ns2:id>
      </article>
      <article>
        <ns2:name xmlns:ns2='http://predic8.com/material/1/'>foo1</ns2:name>
        <ns2:description xmlns:ns2='http://predic8.com/material/1/'>bar1</ns2:description>
        <ns2:price xmlns:ns2='http://predic8.com/material/1/'>
<!-- This element is required and should be filled. -->
          <ns3:amount xmlns:ns3='http://predic8.com/common/1/' />
          <ns3:currency xmlns:ns3='http://predic8.com/common/1/'></ns3:currency>
        </ns2:price>
        <ns2:id xmlns:ns2='http://predic8.com/material/1/'>1</ns2:id>
      </article>
    </ns1:create>
  </s11:Body>
</s11:Envelope>

carlvine500 avatar Jun 21 '18 06:06 carlvine500