on 08-31-2005 2:45 PM
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
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);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.