cancel
Showing results for 
Search instead for 
Did you mean: 

How to HTTP POST data to SAP Business Connector

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

}