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 30 31 32 33 34 35 36 37 38 39 40 41 42
| public static void main(String[] args) {
try {
String xmldata = "<?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>PSTKJava "+(System.currentTimeMillis())+"</arg0>" +
"</ns2:createDeal>" +
"</S:Body></S:Envelope> ";
// /ServiceDomaineBean/ServiceDomaineBeanService?WSDL
//Create socket
String hostname = "172.17.1.43";
int port = 7001;
InetAddress addr = InetAddress.getByName(hostname);
Socket sock = new Socket(addr, port);
//Send header
String path = "//ServiceDomaineBeanSecure/ServiceDomaineBeanSecureService";
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(),"UTF-8"));
// You can use "UTF8" for compatibility with the Microsoft virtual machine.
wr.write("POST " + path + " HTTP/1.0\r\n");
//wr.write("Authorization: Basic dXRpbGlzYXRldXIxOnV0aWxpc2F0ZXVyMQ==\r\n");
wr.write("Host: FXP-350.p.local:7001\r\n");
wr.write("Content-Length: " + xmldata.length() + "\r\n");
wr.write("Content-Type: text/xml; charset=\"utf-8\"\r\n");
wr.write("\r\n");
//Send data
wr.write(xmldata);
wr.flush();
// Response
BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String line;
while((line = rd.readLine()) != null)
System.out.println(line);
} catch (Exception e) {
e.printStackTrace();
} |
Partager