java 客户端的例子:
package post;
import org.apache.soap.*;
import org.apache.soap.messaging.*;
import java.io.*;
import java.net.Socket;
import org.dom4j.*;
import org.dom4j.io.*;public class post {
public void send(String xml) { System.out.println("Starting Test soap...");
Socket server;
InputStream from_server = null;
OutputStream to_server = null;
//String m_ip= "221.130.33.24";
String m_ip= "192.168.22.36";
int m_port= 8080;
String rcode="";
String s ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n"
+ "<SOAP-ENV:Envelope\r\n"
+ "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n"
+ "xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n"
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n"
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\r\n"
+ "SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n"
+ "xmlns=\"http://www.monternet.com/dsmp/schemas/\">\r\n"
+ "<SOAP-ENV:Header>\r\n"
+ "<TransactionID xmlns=\"http://www.monternet.com/dsmp/schemas/\" xsi:type=\"xsd:string\">1231341234567890</TransactionID>\r\n"
+ "</SOAP-ENV:Header>\r\n"
+ "<SOAP-ENV:Body>\r\n"
+ "<UnSubscribeServiceReq xmlns=\"http://www.monternet.com/dsmp/schemas/\">\r\n"
+ "<Version>1.5.0</Version>\r\n"
+ "<MsgType>UnSubscribeServiceReq</MsgType>"
+ "<Send_Address>"
+ "<DeviceType>400</DeviceType>"
+ "<DeviceID>901134</DeviceID>"
+ "</Send_Address>"
+ "<Dest_Address>"
+ "<DeviceType>0</DeviceType>"
+ "<DeviceID>0001</DeviceID>"
+ "</Dest_Address>"
+ "<FeeUser_ID>"
+ "<UserIDType>1</UserIDType>"
+ "<MSISDN>13980038003</MSISDN>"
+ "<PseudoCode/>"
+ "</FeeUser_ID>"
+ "<DestUser_ID>"
+ "<UserIDType>1</UserIDType>"
+ "<MSISDN>13980038003</MSISDN>"
+ "<PseudoCode/>"
+ "</DestUser_ID>"
+ "<Service_ID>"
+ "<ServiceIDType>1</ServiceIDType>"
+ "<SPID>901134</SPID>"
+ "<SPServiceID>-TVBBT</SPServiceID>"
+ "<AccessNo/>"
+ "<FeatureStr/>"
+ "</Service_ID>"
+ "</UnSubscribeServiceReq>"
+ "</SOAP-ENV:Body>"
+ "</SOAP-ENV:Envelope>";
//String s2 = "/dsmp/dsmp.wsdl";
String s2 = "/ss.jsp";
String s3 = "POST " + s2 + " HTTP/1.1" + "\r\n" + "HOST: " + m_ip + "\r\n" +
"Content-Type: text/xml; charset=utf-8" + "\r\n" + "Content-Length: " + s.length() +
"\r\n" + "Connection: Keep-Alive" + "\r\n" +
"SOAPAction: \"sim.UnSubscribeServiceReq\"\r\n\r\n" + s;
try{
byte abyte0[] = s3.getBytes("GB2312");
server = new Socket(m_ip, m_port);
from_server = server.getInputStream();
to_server = server.getOutputStream();
to_server.write(abyte0, 0, abyte0.length);
byte abyte1[] = new byte[5120];
int l = from_server.read(abyte1);
do{
if(l <= 0)
break;
s = s + new String(abyte1, "GB2312");
if(s.indexOf("Envelope>") >= 0)
{
int i1 = s.indexOf("<hRet>");
int j1 = s.indexOf("</hRet>");
rcode=s.substring(i1,j1);
rcode=rcode.substring(6,rcode.length());
}
l = from_server.read(abyte1);
} while(true);
}catch (Exception e) {
System.out.println(e.getMessage());
} }
}
package post;
import org.apache.soap.*;
import org.apache.soap.messaging.*;
import java.io.*;
import java.net.Socket;
import org.dom4j.*;
import org.dom4j.io.*;public class post {
public void send(String xml) { System.out.println("Starting Test soap...");
Socket server;
InputStream from_server = null;
OutputStream to_server = null;
//String m_ip= "221.130.33.24";
String m_ip= "192.168.22.36";
int m_port= 8080;
String rcode="";
String s ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n"
+ "<SOAP-ENV:Envelope\r\n"
+ "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n"
+ "xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n"
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n"
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\r\n"
+ "SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n"
+ "xmlns=\"http://www.monternet.com/dsmp/schemas/\">\r\n"
+ "<SOAP-ENV:Header>\r\n"
+ "<TransactionID xmlns=\"http://www.monternet.com/dsmp/schemas/\" xsi:type=\"xsd:string\">1231341234567890</TransactionID>\r\n"
+ "</SOAP-ENV:Header>\r\n"
+ "<SOAP-ENV:Body>\r\n"
+ "<UnSubscribeServiceReq xmlns=\"http://www.monternet.com/dsmp/schemas/\">\r\n"
+ "<Version>1.5.0</Version>\r\n"
+ "<MsgType>UnSubscribeServiceReq</MsgType>"
+ "<Send_Address>"
+ "<DeviceType>400</DeviceType>"
+ "<DeviceID>901134</DeviceID>"
+ "</Send_Address>"
+ "<Dest_Address>"
+ "<DeviceType>0</DeviceType>"
+ "<DeviceID>0001</DeviceID>"
+ "</Dest_Address>"
+ "<FeeUser_ID>"
+ "<UserIDType>1</UserIDType>"
+ "<MSISDN>13980038003</MSISDN>"
+ "<PseudoCode/>"
+ "</FeeUser_ID>"
+ "<DestUser_ID>"
+ "<UserIDType>1</UserIDType>"
+ "<MSISDN>13980038003</MSISDN>"
+ "<PseudoCode/>"
+ "</DestUser_ID>"
+ "<Service_ID>"
+ "<ServiceIDType>1</ServiceIDType>"
+ "<SPID>901134</SPID>"
+ "<SPServiceID>-TVBBT</SPServiceID>"
+ "<AccessNo/>"
+ "<FeatureStr/>"
+ "</Service_ID>"
+ "</UnSubscribeServiceReq>"
+ "</SOAP-ENV:Body>"
+ "</SOAP-ENV:Envelope>";
//String s2 = "/dsmp/dsmp.wsdl";
String s2 = "/ss.jsp";
String s3 = "POST " + s2 + " HTTP/1.1" + "\r\n" + "HOST: " + m_ip + "\r\n" +
"Content-Type: text/xml; charset=utf-8" + "\r\n" + "Content-Length: " + s.length() +
"\r\n" + "Connection: Keep-Alive" + "\r\n" +
"SOAPAction: \"sim.UnSubscribeServiceReq\"\r\n\r\n" + s;
try{
byte abyte0[] = s3.getBytes("GB2312");
server = new Socket(m_ip, m_port);
from_server = server.getInputStream();
to_server = server.getOutputStream();
to_server.write(abyte0, 0, abyte0.length);
byte abyte1[] = new byte[5120];
int l = from_server.read(abyte1);
do{
if(l <= 0)
break;
s = s + new String(abyte1, "GB2312");
if(s.indexOf("Envelope>") >= 0)
{
int i1 = s.indexOf("<hRet>");
int j1 = s.indexOf("</hRet>");
rcode=s.substring(i1,j1);
rcode=rcode.substring(6,rcode.length());
}
l = from_server.read(abyte1);
} while(true);
}catch (Exception e) {
System.out.println(e.getMessage());
} }
}
解决方案 »
- window7旗舰版安装tomcat7.0.29启动没错,却打不开欢迎界面
- 数据库连接错误
- 登录问题
- 用java程序如何判断远程机器连接正常并能提供WEB服务---------※急※
- servlet连接mysql数据库的问题:unhandled exception type classnotfoundexception
- 怎样让weblogic启动就自动运行类
- jsp使用JNDI数据源连接Mysql数据库出现中文乱码,不要别写数据类型转换的方法,还有什么可以解决这个问题?
- struts求助:执行action后如何返回原来的页面(在线等)
- “soundbox.ejbgrpx”: spaces in the temporary directory path may cause weblogic EJBC utility to produce fatal compile errors
- 测试EJB时候的问题!!看看对你有好处!!!
- struts里报了一个Read of HTTP Request POST parameters failed: Connection reset的错,哪位知道为什么?
- sysdeo tomcat插件问题
{
URL httpurl = new URL(url);
HttpURLConnection httpConn = (HttpURLConnection)httpurl.openConnection();
httpConn.setRequestMethod( "POST" );
httpConn.setRequestProperty("Host",host);
httpConn.setRequestProperty("Content-Type",contype);
httpConn.setRequestProperty( "Content-Length",String.valueOf(postStr.length()));
httpConn.setRequestProperty("SOAPAction",soapaction);
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
PrintWriter out = new PrintWriter(httpConn.getOutputStream());
out.print(xml参数);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
result += inputLine+"\n";
}
in.close();
return result;
}