关于.asmx webservice的问题,请高手指教下 别人给了我个地址http://ip/Socialchannelmanager/ws_smssend.asmx,怎么实现在JAVA中传参,进行调用呢?或者除了这个地址还需要什么条件呢?请高手赐教下啊! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好像asp.net一般给别人的是这样的,有的也可以用后跟wsdl的路径访问。你可以用soapui工具查看。 已经解决了,贴出来以后参考!输入接口地址,点击方法名得到如下内容:(红色字体在调用过程中有用到)send测试测试窗体只能用于来自本地计算机的请求。 SOAP 1.1以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。POST /Socialchannelmanager/ws_smssend.asmx HTTP/1.1Host: 135.34.11.108Content-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "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 OKContent-Type: text/xml; charset=utf-8Content-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.1Host: 135.34.11.108Content-Type: application/soap+xml; charset=utf-8Content-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 OKContent-Type: application/soap+xml; charset=utf-8Content-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(); } }} 新手问servlet和网页的关系 求一个实名认证的程序 IE和火狐页面怎么高亮显示? java 折线图 求解TOMCAT关闭的原因 文件下载时如何指定文件后缀名? 晕倒,请帮忙看看 为什么发不出去? 纯java代码如何获取视频缩略图,各种格式 关于spring注解的使用问题 求教JAVA WEB开发的好视频,(或者专门介绍Struts;jsp.servlet也可) 用JSP的时候空指针异常是什么原因
测试窗体只能用于来自本地计算机的请求。
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();
}
}}