This project is read-only.
2

Resolved

TSoap After sending one successful request

description

The TSoap object tested in job testSoap 0.1 works correctly to send one request as when we try to add an item it adds an item in Innovator. But it raises an exception and actually crashes the job.
 
For example with this soap request:
 
End-Point : "http://xxx.xxx.xxx.xxx/Innovator/Server/InnovatorServer.aspx?&DATABASE=IETL_Project&AUTHUSER=admin&AUTHPASSWORD=607920b64fe136f9ab2389e371852af2"
soap action : "applyItem"
 
"
<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:aras=\"http://www.aras.com/\">
<soap:Header/>
<soap:Body>
  <aras:ApplyItem>
   <Item action=\"add\" type=\"Document\">
    <item_number>1212404093490</item_number>
    <name>grfe21212gerg</name>
   </Item>
  </aras:ApplyItem>
</soap:Body>
</soap:Envelope>
"
 
 
The document gets created in Aras Innovator but the job crashes with the following message:
 
[statistics] connecting to socket on port 3919
[statistics] connected
6 févr. 2011 16:08:10 com.sun.xml.internal.messaging.saaj.soap.impl.BodyImpl extractContentAsDocument
GRAVE: SAAJ0250: Cannot extract Document from body
Exception in component tSOAP_1
javax.xml.soap.SOAPException: Cannot extract Document from body
at com.sun.xml.internal.messaging.saaj.soap.impl.BodyImpl.extractContentAsDocument(Unknown Source)
at org.talend.soap.SOAPUtil.extractContentAsDocument(SOAPUtil.java:143)
at org.talend.soap.SOAPUtil.invokeSOAP(SOAPUtil.java:120)
at innovatoretl.testsoap_0_1.testSoap.tSOAP_1Process(testSoap.java:864)
at innovatoretl.testsoap_0_1.testSoap.runJobInTOS(testSoap.java:1314)
at innovatoretl.testsoap_0_1.testSoap.main(testSoap.java:1185)
[statistics] disconnected
Job testSoap terminé à 16:08 06/02/2011. [Code sortie=1]

comments

aponceot wrote Mar 2, 2011 at 3:32 PM

Same problem for me...

I think it is related to the tsoap component. I tried to send the same SOAP message from talend and from a vbs script. Talend return the error while the vbs script returns a correct xml message...
When debugging step to step the generated Java code in Talend, we can see that the soapUtil_tSOAP_1.invokeSOAP is the problem. But we can not step to step debug this library...

wrote Mar 3, 2011 at 8:29 PM

aponceot wrote Mar 3, 2011 at 8:39 PM

I did not succeed to make the tsoap component to work so I decided to use java code in order to manage the http connection in order to send the SOAP message.

In order to do that, i've just replaced the tSOAP_1 component by a tJava one and placed this code in the component settings :
            String nameSpace = "http://www.aras-corp.com/";
            String remoteMethod = "ApplyItem";
            String characterEncoding = "UTF-8";
            String SOAPmessage = "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><SOAP-ENV:Body><ApplyItem xmlns:m='http://www.aras-corp.com/'>" + context.XML_Buffer + "</ApplyItem></SOAP-ENV:Body></SOAP-ENV:Envelope>";
            // Create new URL object and HttpURLConnection object
            java.net.URL url = new java.net.URL(context.ArasServerAdress);
            java.net.HttpURLConnection httpConnection = (java.net.HttpURLConnection) url.openConnection();

            // Convert the message to a byte array
            byte[] messageBytes = SOAPmessage.getBytes();

            // Set headers
            httpConnection.setRequestProperty("Content-Length", String.valueOf(messageBytes.length));
            httpConnection.setRequestProperty("Content-Type","text/xml; charset=" + characterEncoding + "\"");
            httpConnection.setRequestProperty("SOAPAction", remoteMethod);
            httpConnection.setRequestMethod("POST");
            httpConnection.setRequestProperty("AUTHUSER", context.ArasServerLogin);
            httpConnection.setRequestProperty("AUTHPASSWORD", context.ArasServerPassword);
            httpConnection.setRequestProperty("DATABASE", context.ArasServerDb);
            httpConnection.setDoInput(true);
            httpConnection.setDoOutput(true);

            // Write and send the SOAP message
            java.io.OutputStream out = httpConnection.getOutputStream();
            out.write(messageBytes);
            out.close();

            // Read server response
            java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(
                    httpConnection.getInputStream()));

            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                System.out.println(inputLine);
            }

yoannmaingon wrote Mar 4, 2011 at 6:26 AM

BIG YEEESSS !!!
Thanx for the input, i just tried it and it works superwell !
I'll commit it today, make a video and deliver it as a first Release.

Thanx Anthony !

wrote Mar 4, 2011 at 6:27 AM

wrote Feb 13, 2013 at 7:55 PM

wrote May 16, 2013 at 2:47 AM

wrote May 16, 2013 at 2:47 AM

wrote Jun 14, 2013 at 8:16 AM