Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem creating request with more when one item. #241

Open
kkirakosyan opened this issue Aug 27, 2015 · 3 comments
Open

Problem creating request with more when one item. #241

kkirakosyan opened this issue Aug 27, 2015 · 3 comments

Comments

@kkirakosyan
Copy link

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.

@psytester
Copy link

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 ;-)

@keshavarzi
Copy link

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.

@carlvine500
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants