3

I'm making a Java SOAP call to a WS on SAP PI.

Tried with a curl and it worked well, getting a response. Is there something to do more on Java that I miss?

Trying with the code below, I got the following response:

<?xml version='1.0'?>
<!-- see the documentation -->
<SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'>
  <SOAP:Body>
    <SOAP:Fault>
      <faultcode>SOAP:Server</faultcode>
      <faultstring>Server Error</faultstring>
      <detail>
        <s:SystemError xmlns:s='http://sap.com/xi/WebService/xi2.0'>
          <context>XIAdapter</context>
          <code>ADAPTER.JAVA_EXCEPTION</code>
          <text><![CDATA[
See log trace with id: n/a
          ]]></text>
        </s:SystemError>
      </detail>
    </SOAP:Fault>
  </SOAP:Body>
</SOAP:Envelope>

Here's the Java code:

String body = "body xml and validated ";
                    StringEntity stringEntity = new StringEntity(body, "UTF-8");
            stringEntity.setChunked(true);
            String soapAction = "ActionOut";
        
            HttpPost httpPost = new HttpPost("http://x.x.x.x:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BSY_IBMMDM_T&receiverParty=&receiverService=&interface=ActionOut&interfaceNamespace=urn:yyyy.com:IBMMDM:AdobeForms");


            UsernamePasswordCredentials creds = new UsernamePasswordCredentials("usr", "psw");
            httpPost.addHeader(new BasicScheme().authenticate(creds, httpPost, null));
            httpPost.setEntity(stringEntity);

            httpPost.addHeader("Accept", "text/xml; charset=utf-8");
            httpPost.addHeader("SOAPAction", soapAction);

            // Execute and get the response.
            HttpClient httpClient = new DefaultHttpClient();

            HttpResponse response = httpClient.execute(httpPost);

            HttpEntity entity = response.getEntity();
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
DanieleO
  • 462
  • 1
  • 7
  • 20
  • You clearly don't send the same HTTP request(s) as CURL, so please at least post the CURL so that people can tell you what you did differently in java. – Sandra Rossi Jan 11 '20 at 08:51
  • Where is your curl? How do you authenticate? Seems like auth issue – Suncatcher Jan 11 '20 at 15:13
  • 1
    `<![CDATA[ See log trace with id: n/a` the most reliable debugging approach here would be to check what it suggests (PI trace), not to read tea leaves – Suncatcher Jan 11 '20 at 15:14
  • Hello, thanks for the answer. Issue was that WSDL was not compliant to the XML Call. PI was under my governance, i was just sending request to it but did not have access. I close the Question. Also .setContentType("application/xml"); was needed on the java code. – DanieleO Jan 21 '20 at 11:44
  • @DanieleO If you solved your problem it is suggested to post solution as answer and then accept it later. Then question will be clearly marked as resolved. – Piro Feb 04 '21 at 08:31

1 Answers1

0

you need to verify ,is there any special character in raw data .

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30412754) – Procrastinator Nov 24 '21 at 07:04