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

解决方案 »

  1.   

    public String bind() throws Exception
    {
            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;
        }