别人给了我个地址http://ip/Socialchannelmanager/ws_smssend.asmx,
怎么实现在JAVA中传参,进行调用呢?
或者除了这个地址还需要什么条件呢?请高手赐教下啊!

解决方案 »

  1.   

    好像asp.net一般给别人的是这样的,有的也可以用后跟wsdl的路径访问。你可以用soapui工具查看。
      

  2.   

    已经解决了,贴出来以后参考!输入接口地址,点击方法名得到如下内容:(红色字体在调用过程中有用到)send测试
    测试窗体只能用于来自本地计算机的请求。 
    SOAP 1.1
    以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。POST /Socialchannelmanager/ws_smssend.asmx HTTP/1.1
    Host: 135.34.11.108
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://tempuri.org/send"<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <send xmlns="http://tempuri.org/">
          <account>string</account>
          <passwd>string</passwd>
          <to>string</to>
          <content>string</content>
        </send>

      </soap:Body>
    </soap:Envelope>
    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Content-Length: length<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <sendResponse xmlns="http://tempuri.org/">
          <sendResult>string</sendResult>
        </sendResponse>
      </soap:Body>
    </soap:Envelope>
    SOAP 1.2
    以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。POST /Socialchannelmanager/ws_smssend.asmx HTTP/1.1
    Host: 135.34.11.108
    Content-Type: application/soap+xml; charset=utf-8
    Content-Length: length<?xml version="1.0" encoding="utf-8"?>
    <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
      <soap12:Body>
        <send xmlns="http://tempuri.org/">
          <account>string</account>
          <passwd>string</passwd>
          <to>string</to>
          <content>string</content>
        </send>
      </soap12:Body>
    </soap12:Envelope>
    HTTP/1.1 200 OK
    Content-Type: application/soap+xml; charset=utf-8
    Content-Length: length<?xml version="1.0" encoding="utf-8"?>
    <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
      <soap12:Body>
        <sendResponse xmlns="http://tempuri.org/">
          <sendResult>string</sendResult>
        </sendResponse>
      </soap12:Body>
    </soap12:Envelope>在Java中调用接口代码如下:import org.apache.axis.client.*;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.ParameterMode;
    import javax.xml.rpc.encoding.XMLType;public class TestWebService {/**
    * 使用webservice发送短信
    */
    public static void main(String[] args) {
       // TODO Auto-generated method stub 
       System.out.println("Start invoking....");
       try
       {
         String endPoint="http://135.34.8.108/Socialchannelmanager/ws_smssend.asmx";////提供接口的地址
     String nameSpace = "http://tempuri.org/";//命名空间,根据服务器方的配置来决定,具体在IE地址栏输入接口地址可以得到
         Service service = new Service();
         Call call = (Call)service.createCall();
         call.setTargetEndpointAddress(new java.net.URL(endPoint));
         call.setUseSOAPAction(true);
         call.setSOAPActionURI(String nameSpace+"send");   
         call.setOperationName(new QName(nameSpace,"send"));//设置要调用哪个方法
    //设置参数名称
         call.addParameter(new QName(nameSpace,"account"),XMLType.XSD_STRING,ParameterMode.IN);
         call.addParameter(new QName(nameSpace,"password"),XMLType.XSD_STRING,ParameterMode.IN);
         call.addParameter(new QName(nameSpace,"to"),XMLType.XSD_STRING,ParameterMode.IN);
         call.addParameter(new QName(nameSpace,"content"),XMLType.XSD_STRING,ParameterMode.IN);
         call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);  //要返回的数据类型
    //调用服务,并传参
         String str=(String)call.invoke( new Object[]{"","","15354902240","test"}); 
         System.out.println(str);             
       }catch(Exception e)
       {
         e.printStackTrace();
       }   
    }}