Skip to Content
author's profile photo
Former Member

How to HTTP POST data to SAP Business Connector

Hello,

I would like to transfer data from a client with HTTP POST to SAP Business Connector. SAP BC acts as server. In SAP BC I created a Java service containing the code:

IDataCursor idatacursor = pipeline.getCursor();

idatacursor.first("node");

Object obj1 = idatacursor.getValue();

System.out.println(obj1.toString()); //for test

But how can I access the data that was sent with HTTP POST in my service?

Thank you

Piotr Dudzik

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • author's profile photo
    Former Member
    Oct 06, 2005 at 01:11 PM

    Hi,

    quite easy:

    StringBuffer buffer = new StringBuffer();

    String resultString = null;

    String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+

    "<biztalk_1 xmlns=\"urn:biztalk-org:biztalk:biztalk_1\">"+

    "<header>"+

    "<delivery>"+

    "<to>"+

    "<address>urn:sap-com:logical-system:XXX</address>"+

    "</to>"+

    "<from>"+

    "<address>urn:sap-com:logical-system:YYY</address>"+

    "</from>"+

    "</delivery>"+

    "</header>"+

    "<body>"+

    "<doc:Z_RFC_CALL_NAME> xmlns:doc=\"urn:sap-com:document:sap:rfc:functions\" xmlns=\"\">"+

    ... [PARAMETERS]

    "</doc:Z_RFC_CALL_NAME>"+

    "</body>"+

    "</biztalk_1>";

    try {

    URL url = new URL(SCHEMA, this.host, Integer.parseInt(PORT), FILE);

    HttpURLConnection connection = (HttpURLConnection)url.openConnection();

    initConnection(connection);

    OutputStream out = connection.getOutputStream();

    out.write(xmlString.getBytes());

    out.close();

    InputStream reader = connection.getInputStream();

    char ch;

    while((ch = (char)reader.read()) != -1 && ch != 0xFFFF)

    buffer.append(ch);

    resultString = buffer.toString();

    if (this.getXMLEntry(resultString, "E_STATUS").equals("E")) { // ERROR

    System.out.println("errormessage: "+this.getXMLEntry(resultString, "E_EMSG"));

    } else {

    // ok, is supose this is an S (success), parse the stuff

    ....

    }

    reader.close();

    }

    catch (Exception e){

    e.printStackTrace();

    System.out.println(e);

    }

    Add comment
    10|10000 characters needed characters exceeded