1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| String data =
"<?xml version='1.0' encoding='utf-8'?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<S:Body>"+//<ns2:createDeal xmlns:ns2=\"http://service.p.com/\">" + "<arg0>pastek.Java " + System.currentTimeMillis() </arg0></ns2:createDeal></S:Body></S:Envelope>";
"<ns2:SendTransaction xmlns:ns2=\"http://service.p.com/\"><Code>"+pCode+"</Code><Data>"+new String(Base64.encode(pData.getBytes()))+"</Data></ns2:SendTransaction></S:Body></S:Envelope>";
URL url = new URL("http://fxp-350:7001/ShipSoap/ShipSoapService");
logger.exiting(this.getClass().getName(), "sendTransaction");
URLConnection conn = url.openConnection();
// Set connection parameters.
conn.setDoInput (true);
conn.setDoOutput (true);
conn.setUseCaches (false);
// Make server believe we are form data...
conn.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\"");
conn.setRequestProperty("Authorization", "Basic "+ new String(Base64.encode("trader1000:trader1000".getBytes())));
DataOutputStream out = new DataOutputStream (conn.getOutputStream ());
// Write out the bytes of the content string to the stream.
out.writeBytes(data);
out.flush ();
out.close ();
// Read response from the input stream.
BufferedReader in = new BufferedReader (new InputStreamReader(conn.getInputStream ()));
String temp;
while ((temp = in.readLine()) != null){
response += temp + "\n";
}
temp = null;
in.close (); |
Partager