cancel
Showing results for 
Search instead for 
Did you mean: 

XML inputs in a MII transaction to be used as a Web Service call

Former Member
0 Kudos

Hello experts,

I would like your input in how to use a XML input in a MII transaction that will mostly be used as a web service call.

I've searched the Forum for any responses, but from what I've read it seems that there is no way that you can set up a XML input that will be included in the Web Service WSDL. Is that a true statement, or is there a way of doing it? When you set up a XML input, there is a field to select the XSD file that describes the XML. I've tryed doing that, but it seems that MII just ignores the XSD...

The root problem is that I need to receive a list of inputs that are a structure of 7 elements, and the list size can have 0 to 10 entries. I've worked a lot with Service oriented programming and it is very straight forward to do that with web services, but I am having a very hard time trying to do this in MII.

I am using MII 12.1

Thanks in advance,

Marcelo

Accepted Solutions (1)

Accepted Solutions (1)

former_member4529
Active Contributor
0 Kudos

Hi Marcelo,

From SP04 of MII 12.1 onwards this issue has been corrected and it works now as I tested. Refer the SAP Note 1421427.

You need to specify the xsd which follows the rules as defined in the SAP Note. Also specify the root element to be considered for the XML structure of the transaction parameter in the Elements drop-down while defining the transaction property in the BLS. You can save the xsd in the workbench and refer it as DB://<project>/<folder>/<filename>

Thanks,

Dipankar

Former Member
0 Kudos

Hi Dipankar,

thanks a lot for your help.

I've read the note 1421427 and changed the XSD to work.

The note states that:

The imported XSD must match the following rules:

1) It must have a "targetNamespace" defined. This is the namespace that

will be used with the import statement.

2) If a default namespace "xmlns" is specified in the imported XSD it must

have the same value as the target namespace. If the value is different

from target namespace the import will fail and the WSDL will not be able to

be parsed by most clients. It is ok to ommit the default namespace.

3) You may only pick elements from the target namespace as the structure to

use for the transaction property.

So I changed the header on my XSD

From:

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

To:

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

targetNamespace="http://www.w3.org/2001/XMLSchema">

Now when I assign that XSD to the XML input it shows the elements in the drop down box and the WSDL is generated with a reference to the XSD file.

I am still having trouble to import this WSDL file into a client (tried both MS Visual Studio 10 and SoapUI) but got errors on both. It seems that they can't find the reference to the elements that are defined within the XSD file.

Here is the full XSD file, if anyone can find any problems with it, please let me know:

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

targetNamespace="http://www.w3.org/2001/XMLSchema">

<xs:complexType name="GoodsMovement">

<xs:sequence>

<xs:element name="MaterialNum" type="xs:String"/>

<xs:element name="Plant" type="xs:String"/>

<xs:element name="StorageLocation" type="xs:String"/>

<xs:element name="BatchNum" type="xs:String"/>

<xs:element name="Quantity" type="xs:String"/>

<xs:element name="UnitOfMeasure" type="xs:String"/>

<xs:element name="GMCode" type="xs:String"/>

</xs:sequence>

</xs:complexType>

<xs:element name="GoodsMovementList">

<xs:complexType>

<xs:sequence>

<xs:element name="GoodsMovement" type="GoodsMovement"/>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>

Former Member
0 Kudos

The WSDL generated by MII looks like this:

<?xml version="1.0" encoding="UTF-8" ?>

- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mii0="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://www.sap.com/xMII" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://www.sap.com/xMII">

- <!-- Types -->

- <types>

- <s:schema elementFormDefault="qualified" targetNamespace="http://www.sap.com/xMII">

<s:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://10.1.10.14:51100/XMII/WSDLGen/db/Interface/XSD/GoodsMovementList.xsd" />

- <s:complexType name="InputParams">

- <s:sequence id="InputSequence">

- <s:element maxOccurs="1" minOccurs="0" name="GoodsMovementList">

- <s:complexType>

- <s:sequence>

<s:element ref="mii0:GoodsMovement" />

</s:sequence>

</s:complexType>

</s:element>

</s:sequence>

</s:complexType>

.....

That is the beginning of the WSDL file.

When importing that into a Web Service client, it fails with an error message stating that it cannot find the GoodsMovement element that should be described in the XSD file. I've tested the address on the schema location on my browser and I do get the XSD file...

former_member4529
Active Contributor
0 Kudos

Hi,

You need to change the xsd a bit as below:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  xmlns:s0="http://www.w3.org/2001/XMLSchema"  targetNamespace="http://www.w3.org/2001/XMLSchema">

<xs:complexType name="GoodsMovement">
<xs:sequence>
<xs:element name="MaterialNum" type="xs:string"/>
<xs:element name="Plant" type="xs:string"/>
<xs:element name="StorageLocation" type="xs:string"/>
<xs:element name="BatchNum" type="xs:string"/>
<xs:element name="Quantity" type="xs:string"/>
<xs:element name="UnitOfMeasure" type="xs:string"/>
<xs:element name="GMCode" type="xs:string"/>
</xs:sequence>
</xs:complexType>

<xs:element name="GoodsMovementList">
<xs:complexType>
<xs:sequence>
<xs:element name="GoodsMovement" type="s0:GoodsMovement"/>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

Two things have been changed/added :

1) String datatype is written as string (small-case)

2) Namespace-prefix added for GoodsMovement element while referring it.

Now it should work fine.

Thanks,

Dipankar

Former Member
0 Kudos

Hi Dipankar,

thanks a lot for your help.

I've got it to work and generate the correct WSDL now.

I'm still having some issues with importing the WSDL in MS Visual Studio, but I'm pretty sure it is because of the imported schema. It is referenced by its URL and there might be some authentication issue or something that is giving me some errors. But that is probably a VS problem, the WSDL seems to be fine.

One extra question that you might be able to help me with:

now that I have the XML input, I believe I have to use a Reference Schema Loader, is that correct?

I've never used these XML inputs, so sorry for the basic questions... I just want to access the XML elements from within the MII transaction.

Thanks again for helping me on this problem!

Regards,

Marcelo

Former Member
0 Kudos

I believe I need some help again...

I've used the corrected XSD in the XML Transaction Property and the WSDL for the Web Service was generated fine.

When I import the WSDL in a SOAP client, I can create a sample request with all the fields in the XML to call the web service, but if I do the call from the client I get the error:


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>while trying to invoke the method java.lang.String.equals(java.lang.Object) of an object loaded from local variable 'name'</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

If I try to set the property value within MII with a valid XML, I get the error message: "Error in Parsing: cvc-elt.1: Cannot find the declaration of element 'GoodsMovementList'.". But the GoodsMovementList is exactly the XML element that MII recognized from the XSD and displayed in the Element drop-down selection. I've even tryed a simple <GoodsMovementList></GoodsMovementList> XML and still get the same error message...

Any ideas?

Thanks,

Marcelo

Edited by: MarceloVieira on Mar 17, 2011 6:54 PM

Former Member
0 Kudos

Hi,

Since we also need the xml as a input, so I tried to use the exactly the same xml which you modified in this reply as a xsd file and saved it in Web tab in Workbench.

Then, I can select the xsd and the Element Name in the Transaction Property Detail. But it pop up a Error messsage: "Premature end of file" when I click button OK.

Do you have any idea about this problem?

Thanks!

former_member4529
Active Contributor
0 Kudos

Hi,

It seems there might be some issue in the BLS logic as I can call the webservice from WSNavigator client as well.

Thanks,

Dipankar

Former Member
0 Kudos

Hi Dipankar,

sorry but I didn't fully understand your response. What do you mean by "might be some issue in the BLS logic"?

Do you mean that there might be something wrong in the transaction itself?

I've created a very simple transaction for testing this.

All it does is receive a XML input, loop through it and create a XML output document that is assigned to a XML output.

the XSD looks like this:


<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  targetNamespace="Test">
 
<xs:element name="TestList">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="100" minOccurs="0" name="Test" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
 
</xs:schema>

The XML input is named TestInput and is assigned with this XSD file using the TestList element.

I wanted to assign a value to this variable in MII, so I could run the transaction locally and see the traces, but if I do that I get that error saying: "Error in Parsing: cvc-elt.1: Cannot find the declaration of element 'GoodsMovementList'."

So I tried calling the webservice from a separate SOAP client to see the response, but then I get the error message:

<faultstring>while trying to invoke the method java.lang.String.equals(java.lang.Object) of an object loaded from local variable 'name'</faultstring>

I'm stuck on this and cannot debug, because I can't assign a value to my variable...

Thanks again for your help on this.

former_member4529
Active Contributor
0 Kudos

Hi,

Can you please assign a XML with values in the default value of the XML property and try running the BLS from the workbench itself by the Execute button and see if it works fine?

Thanks,

Dipankar

Former Member
0 Kudos

That's the problem, I try to assing a simple XML to the input but keep getting the error:

"Error in Parsing: cvc-elt.1: Cannot find the declaration of element 'TestList'."

Even though that is the element that MII recognized from the XSD and is selected in the drop-down box.

The XML that I'm trying to use is:


<TestList>
<Test>1</Test>
<Test>2</Test>
</TestList>

Here is a print-screen of the error:

[http://i79.photobucket.com/albums/j160/bonk22/PrintScreen-1.jpg]

Edited by: MarceloVieira on Mar 18, 2011 4:55 PM

Answers (1)

Answers (1)

Former Member
0 Kudos

Reopening the question: Still not clear on how to assign a value to the XML input.

Anyone have any idea on how to do that?

Edited by: MarceloVieira on Mar 21, 2011 7:09 PM

former_member4529
Active Contributor
0 Kudos

Hi,

You can't provide both the default value XML and the XSD at the same time to the BLS property. If you provide only the XSD it should work. I tested that by creating a BLS with input and output XML property referring to the XSD you are using and inside the BLS simply assigning the input XML to the output XML property. Then invoked the BLS from WSNavigator as a SOAP web service. It works perfectly.

Thanks,

Dipankar

Former Member
0 Kudos

Hi Dipankar,

thanks again for helping out on this.

I've done your test, but am still getting the error:

"<faultstring>while trying to invoke the method java.lang.String.equals(java.lang.Object) of an object loaded from local variable 'name'</faultstring>"

What I did is create a new transaction with one XML input (named TestInput) and one XML output (named TestOutput) and added one assignment action with a link from the Transaction.TestInput to Transaction.TestOutput. Both XMLs properties are assigned to the XSD described below and assigned to the TestList element:


<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  targetNamespace="Test">
 
<xs:element name="TestList">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="100" minOccurs="0" name="Test" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
 
</xs:schema>

In my SOAP client program (currently sing SoapUI), I send the following XML request:


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xmii="http://www.sap.com/xMII" xmlns:test="Test">
   <soapenv:Header/>
   <soapenv:Body>
      <xmii:XacuteRequest>
         <xmii:LoginName>username</xmii:LoginName>
         <xmii:LoginPassword>password</xmii:LoginPassword>
         <xmii:InputParams>
            <xmii:TestInput>
               <test:TestList>
                  <Test>1</Test>
                  <Test>2</Test>
               </test:TestList>
            </xmii:TestInput>
         </xmii:InputParams>
      </xmii:XacuteRequest>
   </soapenv:Body>
</soapenv:Envelope>

And I get the following response:


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>while trying to invoke the method java.lang.String.equals(java.lang.Object) of an object loaded from local variable 'name'</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

I'm running on MII 12.1.8 build 20.

I've also tryed to change the output to a string format (just to get the XML encoded into a string), but still got the same error...

Really appreciate the help on this.

Best regards,

Marcelo

Edited by: MarceloVieira on Mar 22, 2011 8:36 PM

former_member4529
Active Contributor
0 Kudos

Hi Marcelo,

Please check the link type of the assignment action in BLS. It should be of Assign XML. To test whether the BLS is working fine, remove the xsd reference from the input property and simply assign a XML with value in the default value and execute the BLS from workbench. Use tracer to print the output.

I also tested by assigning the input to output both referring to the same xsd via SOAP Web Service (using WSNavigator) and it works fine.

Thanks,

Dipankar

Former Member
0 Kudos

Hi Dipankar,

sorry for all this trouble, but this is getting very frustrating...

I've taken out the XSD from the Input parameter (kept it in the output XML parameter) and set its value to:


<TestList>
<Test>1</Test>
<Test>2</Test>
</TestList>

I ran the transaction, both from the workbench and from the soap client, and it gives me the correct response.

So the problem is really in the XML input with a XSD assigned to it.

Then I made another test: took out the XML value from the input, kept it without the XSD and called the service from the soap client. For that I got the following response:


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Transaction threw an unrecoverable exception:  [com.sap.xmii.bls.exceptions.ParameterValidationException: Error while validating XML against XSD [org.xml.sax.SAXParseException: Premature end of file.]]</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

So it really seems that there is still something wrong with the XSD file. Have you used the exact same XSD that I posted before on this thread and had your transaction working fine? If so, which version/build are you running?

Thanks again for your help!

Regards,

Marcelo

former_member4529
Active Contributor
0 Kudos

Hi Marcelo,

I have just copied the same xsd you have pasted here and used in the BLS and it worked fine. Do you have Validate XML checked in the Transaction property? If yes please remove that and test it once again.

Thanks,

Dipankar

Former Member
0 Kudos

Hi Dipankar,

thanks for the quick response!

I tryed unchecking the "validate XML on execution" from the input parameter and it didn't work.

Tryed again removing both checks from the input and outpu and it still gives me the error message:

<faultstring>while trying to invoke the method java.lang.String.equals(java.lang.Object) of an object loaded from local variable 'name'</faultstring>

Former Member
0 Kudos

Hi Dipankar,

I was trying to assign a reference schema to my input and output parameters to see if that would fix the problem.

I added a "Reference Schema Loader" action in the BLS, configured it to point to the test.xsd file and then assigned the reference document to the input and output parameters. I still got the same error when calling the webservice, but I saw something that caught my attention.

Please check the print screen below:

http://i79.photobucket.com/albums/j160/bonk22/PrintScreen2.jpg

It seems that the TestList element is getting the right namespace assigned to it, but the Test element isn't.

I'm not sure if that is the reason of the problem, but it seemed a bit strange. Any ideas on how to set the Test element namespace in the XSD file?

former_member4529
Active Contributor
0 Kudos

Hi Marcelo,

Sorry for the late reply. Can you please check whether you are getting the below WSDL from WSDLGen service? I am getting the same using the xsd you have provided and able to execute the webservice via WSNavigator.

Thanks,

Dipankar

<?xml version="1.0" encoding="UTF-8"?><definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mii0="Test" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://www.sap.com/xMII" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://www.sap.com/xMII">
    <!-- Types -->
    <types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://www.sap.com/xMII"><s:import namespace="Test" schemaLocation="http://<server>/XMII/WSDLGen/db/Default/WEB/test1.xsd"/>
            <s:complexType name="InputParams">
                <s:sequence id="InputSequence">
                    
                <s:element maxOccurs="1" minOccurs="0" name="Input"><s:complexType><s:sequence><s:element ref="mii0:TestList"/></s:sequence></s:complexType></s:element></s:sequence>
            </s:complexType>
            <s:element name="XacuteRequest">
                <s:complexType>
                    <s:sequence>
                        <s:element maxOccurs="1" minOccurs="0" name="LoginName" type="s:string"/>
                        <s:element maxOccurs="1" minOccurs="0" name="LoginPassword" type="s:string"/>
                        <s:element maxOccurs="1" minOccurs="0" name="InputParams" type="s0:InputParams"/>
                    </s:sequence>
                </s:complexType>
            </s:element>
            <s:complexType name="Rowset">
                <s:sequence>
                    <s:element maxOccurs="unbounded" minOccurs="0" name="Row" type="s0:Row"/>
                </s:sequence>
                <s:attribute name="Message" type="s:string"/>
            </s:complexType>
            <s:complexType name="Row">
                <s:sequence id="RowSequence">
                    
                <s:element maxOccurs="1" minOccurs="1" name="Output"><s:complexType><s:sequence><s:element ref="mii0:TestList"/></s:sequence></s:complexType></s:element></s:sequence>
            </s:complexType>
            <s:element name="XacuteResponse">
                <s:complexType>
                    <s:sequence>
                        <s:element maxOccurs="1" minOccurs="0" name="Rowset" type="s0:Rowset"/>
                    </s:sequence>
                </s:complexType>
            </s:element>
        </s:schema>
    </types>
    <!-- Messages -->
    <message name="XacuteSoapIn">
        <part element="s0:XacuteRequest" name="parameters"/>
    </message>
    <message name="XacuteSoapOut">
        <part element="s0:XacuteResponse" name="parameters"/>
    </message>
    <!-- Ports -->
    <portType name="XacuteWSSoap">
        <operation name="Xacute">
            <input message="s0:XacuteSoapIn"/>
            <output message="s0:XacuteSoapOut"/>
        </operation>
    </portType>
    <!-- Bindings -->
    <binding name="XacuteWSSoap" type="s0:XacuteWSSoap">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="Xacute">
            <soap:operation soapAction="http://www.sap.com/xMII" style="document"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>
    <!-- Service mapping -->
    <service name="XacuteWS">
        <port binding="s0:XacuteWSSoap" name="XacuteWSSoap">
            <soap:address location="http://<server>/XMII/SOAPRunner/Default/TestXML"/>
        </port>
    </service>
</definitions>