电脑win10玩游戏卡顿掉帧 界面卡顿 掉帧 什么原因

56短信网短信文档开发中心( 技术支持:QQ:6585910)
webservice接口开发
说明:,webservice短信接口相对于http来说更加的安全,但开发程度相对http来说要复杂一些,一次可以提交多个号码,您也可以单个号码提交,可以支持各种操作系统和开发语言,只要电脑能上网就可以使用发送短信,可以根据需要开发自己的一套短信平台,也可以与您企业现有的网站、CRM、OA、ERP、手机App等系统或进行无缝对接,轻松实现验证码,通知,提醒等服务,快速拥有无线应用,完善您的服务,提高用户体验。
第一步:调用短信接口地址(api)
/WebServiceInterface.asmx
第二步:如何调用接口地址
1.目前我们提供最常用语言的实例参考(php,asp,java,.net,c#),当然也欢迎大家在开发中如果有更好的,更简单的方法,欢迎贡献源码实例,我们将会有相应的奖励
php实例下载参考
php调用WebService实例:
.net实例下载参考(c#也可以参考以下两个实例)
.ne调用WebService实例:
java实例下载参考
java调用WebService实例:
实例是用来参考的,明白其中的原理后,接入发送短信还是非常简单的,如果您不太懂技术,可以联系技术人员协助您完成接入
第三步:参数说明
(1) 调用方法:
int SendNote(string handtels,string _content,string userName,string password,string cid,string _sendtime,string _smsnumber)
手机号号码,如果是多个号码提交,手机号之间请用逗号隔开,我们设置是1000条提交一次,多于1000条可以自己循环提交发送,单个号码提交后边不要加逗号。
短信内容,支持500个汉字,建议发送在350个字左右,太长了,怕有的手机不支持,每个英文,标点符号,或阿拉伯字符也算1个汉字,行业通道每条64个字
,比如:您发送了100个字,收到的是一条,但按二条计费.此接口支持单发,多发,如果是多个号码提交,手机号之间请用逗号隔开
密码,建议设置比较复杂一些.
参数为空,为立即发送如需要设定发送时间,时间格式:
_smsnumber
所属平台,由56短信网提供
测试的时候,大家切记,不要随边输出一些字母或数字或内容就随边发送,这样很可能造成您的短信收不到或失败,为了保证网关的稳定和短信的速度
大家测试的时候一定要测试正规的业务信息,比如:我是发验证码的,测试的内容一般是:【56短信网】您的验证码是:2idkewl,【56短信网】里边为公司或网站的简单,要换成你们公司或网站的
简称,当然内容是由自己写的,但总之看起来,一定要是正规的,不一定非要按照我们的格式,简单的说,就是你们网站或软件正式上线你们是怎么写的就怎么写.
(2) 返回值说明:
用户名密码不正确
内容不能为空
验证此平台是否存在
手机号不能为空
客户短信数量为0
代表要加签名,签名一般是【网站或公司简称】,比如:您的验证码是:短信网】,如果还是返回-21错误,请参考: /help/1255.html
非法手机号
对某个用户名进行了屏蔽处理
代表发送成功
第四步:高级功能开发
(1) 如果短信接口已经满足了您的需要,可以忽略.
(2) 高级功能开发参考:,您也可以参考http高级功能开发:
第五步:常见问题
(1) 常见错误问题及解决方法请参考:
终于找到好的短信服务商了,赶紧测试一下吧
(#替换成@)
手机扫一扫
版权所有:56短信网 网络经营许可证编号:冀ICP备号匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。10:54 提问
webservice通过url传递参数调用接口,参数中含“/”要怎么处理?
我现在在做一个调用企业QQ接口来发信息的平台,是通过webservice在url传递参数调用接口。。
但是短信内容中含斜杠时会干扰参数的传递,大神教我怎么解决啊?
@Path("/sendTips/{receivers}/{content}/{windowTitle}/{tipsTitle}/{tipsUrl}")
@Produces ({MediaType.APPLICATION_JSON})
public String sendTips(@PathParam("receivers") String receivers, @PathParam("content") String content,
@PathParam("windowsTitle") String windowsTitle, @PathParam("tipsTitle") String tipsTitle,
@PathParam("tipsUrl") String tipsUrl) throws SystemE
按赞数排序
建议url 转义(URLEncoder类)即可,Java里面有方法
可以使用Unicode 编码啊
用URLEncoder进行编码,然后用再用URLDecoder进行解码
可以规定是UTF-8或者GBK之类的 建议UTF-8
其他相似问题温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
在这里是面向程序员的高品质IT技术学习社区,是程序员学习成长的地方。让我们更好地用技术改变世界。请关注新浪微博号: IT国子监(/itguozijian)
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
一、利用jdk web服务api实现,这里使用基于 SOAP message 的 Web 服务&1.首先建立一个Web services EndPoint:&Java代码&package&H&&& &&import&javax.jws.WebS&&& &&import&javax.jws.WebM&&& &&import&javax.xml.ws.E&&& &&&& &&@WebService&& &&public&class&Hello&{&& &&& &&@WebMethod&& &&public&String&hello(String&name)&{&&& &&return&"Hello,&"&+&name&+&"\n";&&& &&}&&& &&&&&& &&&public&static&void&main(String[]&args)&{&&& &&&&&//&create&and&publish&an&endpoint&&&&&&&&&&&&&Hello&hello&=&new&Hello();&&& &&&&&&&&&Endpoint&endpoint&=&Endpoint.publish("http://localhost:8080/hello",&hello);&&&& &&&&&&&&&&}&&& &&}&&&Java代码&package&H&&&&&import&javax.jws.WebS&&&&&import&javax.jws.WebM&&&&&import&javax.xml.ws.E&&&&&&&&&@WebService&&&&public&class&Hello&{&&&&&&&@WebMethod&&&&public&String&hello(String&name)&{&&&&&return&"Hello,&"&+&name&+&"\n";&&&&&}&&&&&&&&&&&&public&static&void&main(String[]&args)&{&&&&&&&&//&create&and&publish&an&endpoint&&&&&&&&&&&&Hello&hello&=&new&Hello();&&&&&&&&&&&&Endpoint&endpoint&=&Endpoint.publish("http://localhost:8080/hello",&hello);&&&&&&&&&&&&&&}&&&&&}&&&2.使用 apt 编译 Hello.java(例:apt -d [存放编译后的文件目录] Hello.java ) ,会生成 jaws目录&3.使用java Hello.Hello运行,然后将浏览器指向http://localhost:8080/hello?wsdl就会出现下列显示&4.使用wsimport 生成客户端&使用如下:wsimport -p . -keep http://localhost:8080/hello?wsdl&5.客户端程序:&Java代码&class&HelloClient{&&& &&public&static&void&main(String&args[])&{&&& &&&&HelloService&service&=&new&HelloService();&&& &&&&Hello&helloProxy&=&service.getHelloPort();&&& &&&&String&hello&=&helloProxy.hello("你好");&&&&&&&&&& &&&&System.out.println(hello);&&& &&&&}&&& &&}&&Java代码&class&HelloClient{&&&&&public&static&void&main(String&args[])&{&&&&&&&HelloService&service&=&new&HelloService();&&&&&&&Hello&helloProxy&=&service.getHelloPort();&&&&&&&String&hello&=&helloProxy.hello("你好");&&&&&&&&&&&&&&System.out.println(hello);&&&&&&&}&&&&&}&&二、使用xfire,我这里使用的是myeclipse集成的xfire进行测试的&利用xfire开发WebService,可以有三种方法:&&&&&& 1一种是从javabean 中生成;&&&&&& 2 一种是从wsdl文件中生成;&&&&&& 3 还有一种是自己建立webservice&步骤如下:&&&& 用myeclipse建立webservice工程,目录结构如下:&&&&&& 首先建立webservice接口,&&&&& 代码如下:&Java代码&package&com.myeclipse.wsE &&//Generated&by&MyEclipse&&&&&public&interface&IHelloWorldService&{ &&&&&& &&&&&&public&String&example(String&message); &&&&&& &&}&&Java代码&package&com.myeclipse.wsE&&//Generated&by&MyEclipse&&&&public&interface&IHelloWorldService&{&&&&&&&&&&&&public&String&example(String&message);&&&&&&&&}&&Java代码&package&com.myeclipse.wsE &&&//Generated&by&MyEclipse&&&& &&&public&class&HelloWorldServiceImpl&implements&IHelloWorldService&{ &&&&&&& &&&&&&&public&String&example(String&message)&{ &&&&&&&&&&&return& &&&&&&&} &&&&&&& &&}&&Java代码&package&com.myeclipse.wsE&&&//Generated&by&MyEclipse&&&&&&public&class&HelloWorldServiceImpl&implements&IHelloWorldService&{&&&&&&&&&&&&&&public&String&example(String&message)&{&&&&&&&&&&&return&&&&&&&&}&&&&&&&&&}&&修改service.xml 文件,加入以下代码:&Xml代码&&&&service&&&&&&&&&&&&name&HelloWorldService&/name&&&&&&&&&&&&serviceClass&&&&&&&&&&&&&&&&com.myeclipse.wsExample.IHelloWorldService &&&&&&&&&&&&/serviceClass&&&&&&&&&&&&&implementationClass&&&&&&&&&&&&&&&com.myeclipse.wsExample.HelloWorldServiceImpl &&&&&&&&&&&&/implementationClass&&&&&&&&&&&&&style&wrapped&/style&&&&&&&&&&&&&use&literal&/use&&&&&&&&&&&&&scope&application&/scope&&&&/service&&&Xml代码&&service&&&&&&&&&&&&name&HelloWorldService&/name&&&&&&&&&&&&serviceClass&&&&&&&&&&&&&&&&com.myeclipse.wsExample.IHelloWorldService&&&&&&&&&&&&/serviceClass&&&&&&&&&&&&&implementationClass&&&&&&&&&&&&&&&com.myeclipse.wsExample.HelloWorldServiceImpl&&&&&&&&&&&&/implementationClass&&&&&&&&&&&&&style&wrapped&/style&&&&&&&&&&&&&use&literal&/use&&&&&&&&&&&&&scope&application&/scope&&&&/service&&&把整个项目部署到tomcat服务器中 ,打开浏览器,输入http://localhost:8989/HelloWorld/services/HelloWorldService?wsdl&客户端实现如下:&Java代码&package&com.myeclipse.wsExample. &&import&java.net.MalformedURLE &&import&java.net.URL; &&&&import&org.codehaus.xfire.XFireF &&import&org.codehaus.xfire.client.C &&import&org.codehaus.xfire.client.XFireProxyF &&import&org.codehaus.xfire.service.S &&import&org.codehaus.xfire.service.binding.ObjectServiceF &&&&import&com.myeclipse.wsExample.IHelloWorldS &&&&public&class&HelloWorldClient&{ &&public&static&void&main(String[]&args)&throws&MalformedURLException,&Exception&{ &&//&TODO&Auto-generated&method&stub&&&Service&s=new&ObjectServiceFactory().create(IHelloWorldService.class); &&XFireProxyFactory&xf=new&XFireProxyFactory(XFireFactory.newInstance().getXFire()); &&String&url="http://localhost:8989/HelloWorld/services/HelloWorldService"; &&&&&&&&&&&&try&&&&&&&&&&{&&&&&&&&&&&& &&&&&&&&&&&&&& &&&&&&&&&&&&&&IHelloWorldService&hs=(IHelloWorldService)&xf.create(s,url); &&&&&&&&&&&&&&String&st=hs.example("zhangjin"); &&&&&&&&&&&&&&System.out.print(st); &&&&&&&&&&} &&&&&&&&&&catch(Exception&e) &&&&&&&&&&{ &&&&&&&&&&&&&&e.printStackTrace(); &&&&&&&&&&} &&&&&} &&&&}&&Java代码&package&com.myeclipse.wsExample.&&import&java.net.MalformedURLE&&import&java.net.URL;&&&&import&org.codehaus.xfire.XFireF&&import&org.codehaus.xfire.client.C&&import&org.codehaus.xfire.client.XFireProxyF&&import&org.codehaus.xfire.service.S&&import&org.codehaus.xfire.service.binding.ObjectServiceF&&&&import&com.myeclipse.wsExample.IHelloWorldS&&&&public&class&HelloWorldClient&{&&public&static&void&main(String[]&args)&throws&MalformedURLException,&Exception&{&&//&TODO&Auto-generated&method&stub&&Service&s=new&ObjectServiceFactory().create(IHelloWorldService.class);&&XFireProxyFactory&xf=new&XFireProxyFactory(XFireFactory.newInstance().getXFire());&&String&url="http://localhost:8989/HelloWorld/services/HelloWorldService";&&&&&&&&&&&&try&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&IHelloWorldService&hs=(IHelloWorldService)&xf.create(s,url);&&&&&&&&&&&&&&String&st=hs.example("zhangjin");&&&&&&&&&&&&&&System.out.print(st);&&&&&&&&&&}&&&&&&&&&&catch(Exception&e)&&&&&&&&&&{&&&&&&&&&&&&&&e.printStackTrace();&&&&&&&&&&}&&&&&}&&&&}&&这里再说点题外话,有时候我们知道一个wsdl地址,比如想用java客户端引用.net 做得webservice,使用myeclipse引用,但是却出现无法通过验证的错误,这时我们可以直接在类中引用,步骤如下:&Java代码&public&static&void&main(String[]&args)&throws&MalformedURLException,&Exception&{ &&&&&&&&&&//&TODO&Auto-generated&method&stub&&&&&&&&&&&Service&s=new&ObjectServiceFactory().create(IHelloWorldService.class); &&&&&&&&&&XFireProxyFactory&xf=new&XFireProxyFactory(XFireFactory.newInstance().getXFire()); &&&&&&&&&&&&&& &&//远程调用.net开发的webservice&&&Client&c=new&Client(new&URL(".cn/webservices/qqOnlineWebService.asmx?wsdl")); &&&&&&&&&&Object[]&o=c.invoke("qqCheckOnline",&new&String[]{"",""}); &&&&&&&&&& &&//调用.net本机开发的webservice&&&Client&c1=new&Client(new&URL("http://localhost/zj/Service.asmx?wsdl")); &&Object[]&o1=c1.invoke("HelloWorld",new&String[]{}); &&&&&&&&&& &&}&&Java代码&public&static&void&main(String[]&args)&throws&MalformedURLException,&Exception&{&&&&&&&&&&//&TODO&Auto-generated&method&stub&&&&&&&&&&Service&s=new&ObjectServiceFactory().create(IHelloWorldService.class);&&&&&&&&&&XFireProxyFactory&xf=new&XFireProxyFactory(XFireFactory.newInstance().getXFire());&&&&&&&&&&&&&&&&//远程调用.net开发的webservice&&Client&c=new&Client(new&URL(".cn/webservices/qqOnlineWebService.asmx?wsdl"));&&&&&&&&&&Object[]&o=c.invoke("qqCheckOnline",&new&String[]{"",""});&&&&&&&&&&&&//调用.net本机开发的webservice&&Client&c1=new&Client(new&URL("http://localhost/zj/Service.asmx?wsdl"));&&Object[]&o1=c1.invoke("HelloWorld",new&String[]{});&&&&&&&&&&&&}&&三、使用axis1.4调用webservice方法&&& 前提条件:下载axis1.4包和tomcat服务器&& ,并将axis文件夹复制到tomcat服务器的webapp文件夹中&&& 这里我就说一下最简单的方法:&&&&&&&&& 首先建立一个任意的java类(例如:HelloWorld.java),复制到axis文件夹下,将其扩展名改为jws,然后重新启动tomcat,在浏览器中输入http://localhost:8989/axis/HelloWorld.jws?wsdl,就会得到一个wsdl文件,其客户端调用方法如下:&Java代码&import&javax.xml.rpc.S &&import&javax.xml.rpc.ServiceE &&import&javax.xml.rpc.ServiceF &&import&java.net.MalformedURLE &&import&java.net.URL; &&import&java.rmi.RemoteE &&import&javax.xml.namespace.QN &&&&public&class&TestHelloWorld&{ &&&&&&&&&&public&static&void&main(String[]&args)&throws&MalformedURLException,&ServiceException,&RemoteException&{ &&&&&&&&&&//&TODO&Auto-generated&method&stub&&&&&&&&&&& &&&&&&&&&&String&wsdlUrl&="http://localhost:8989/axis/HelloWorld.jws?wsdl"; &&&&&&&&&&String&nameSpaceUri&="http://localhost:8989/axis/HelloWorld.jws"; &&&&&&&&&&String&serviceName&=&"HelloWorldService"; &&&&&&&&&&String&portName&=&"HelloWorld"; &&&&&&&&&& &&&&&&&&&&ServiceFactory&serviceFactory&=&ServiceFactory.newInstance(); &&&&&&&&&&Service&afService&=serviceFactory.createService(new&URL(wsdlUrl),new&QName(nameSpaceUri,&serviceName)); &&&&&&&&&&HelloWorldInterface&proxy&=&(HelloWorldInterface)afService.getPort(new&QName(nameSpaceUri,&portName),HelloWorldInterface.class); &&&&&&&&&&System.out.println("return&value&is&"+proxy.getName("john")&)&; &&&&&&&&&& &&&&&&} &&&&}&&Java代码&import&javax.xml.rpc.S&&import&javax.xml.rpc.ServiceE&&import&javax.xml.rpc.ServiceF&&import&java.net.MalformedURLE&&import&java.net.URL;&&import&java.rmi.RemoteE&&import&javax.xml.namespace.QN&&&&public&class&TestHelloWorld&{&&&&&&&&&&public&static&void&main(String[]&args)&throws&MalformedURLException,&ServiceException,&RemoteException&{&&&&&&&&&&//&TODO&Auto-generated&method&stub&&&&&&&&&&&&&&&&&&&&String&wsdlUrl&="http://localhost:8989/axis/HelloWorld.jws?wsdl";&&&&&&&&&&String&nameSpaceUri&="http://localhost:8989/axis/HelloWorld.jws";&&&&&&&&&&String&serviceName&=&"HelloWorldService";&&&&&&&&&&String&portName&=&"HelloWorld";&&&&&&&&&&&&&&&&&&&&ServiceFactory&serviceFactory&=&ServiceFactory.newInstance();&&&&&&&&&&Service&afService&=serviceFactory.createService(new&URL(wsdlUrl),new&QName(nameSpaceUri,&serviceName));&&&&&&&&&&HelloWorldInterface&proxy&=&(HelloWorldInterface)afService.getPort(new&QName(nameSpaceUri,&portName),HelloWorldInterface.class);&&&&&&&&&&System.out.println("return&value&is&"+proxy.getName("john")&)&;&&&&&&&&&&&&&&&&}&&&&}&&四、使用axis2开发webservice(这里首先感谢李宁老师)&&&&& 使用axis2 需要先下载&&&& axis2-1.4.1-bin.zip&&& axis2-1.4.1-war.zip&& http://ws.apache.org/axis2/&&&& 同理,也需要将axis2复制到webapp目录中&在axis2中部署webservice有两种方法,&&&& 第一种是pojo方式,这种方式比较简单,但是有一些限制,例如部署的类不能加上包名&&&& 第二种方式是利用xml发布webservice,这种方法比较灵活,不需要限制类的声明&&&& 下面分别说明使用方法:&&&& 1.pojo方式:在Axis2中不需要进行任何的配置,就可以直接将一个简单的POJO发布成WebService。其中POJO中所有的public方法将被发布成WebService方法。先实现一个pojo类:&Java代码&public&class&HelloWorld{ &&&&&&public&String&getName(String&name) &&&&&&{ &&&&&&&&&&return&"你好&"&+& &&&&&&}&&&& &&&&&&public&int&add(int&a,int&b) &&&&&&{ &&&&&&&&&&return&a+b; &&&&&&}&&&& &&}&&Java代码&public&class&HelloWorld{&&&&&&public&String&getName(String&name)&&&&&&{&&&&&&&&&&return&"你好&"&+&&&&&&&}&&&&&&&&&&public&int&add(int&a,int&b)&&&&&&{&&&&&&&&&&return&a+b;&&&&&&}&&&&&&}&&由于这两个方法都是public类型,所以都会发布成webservice。编译HelloWorld类后,将HelloWorld.class文件放到%tomcat%\webapps\axis2\WEB-INF\pojo目录中(如果没有pojo目录,则建立该目录),然后打开浏览器进行测试:&输入一下url:&&http://localhost:8080/axis2/services/listServices&会列出所有webservice&&&这是其中的两个webservice列表,接着,在客户端进行测试:&首先可以写一个封装类,减少编码,代码如下:&&Java代码&package&MZ.GetWebS &&import&javax.xml.namespace.QN &&&&import&org.apache.axis2.AxisF &&import&org.apache.axis2.addressing.EndpointR &&import&org.apache.axis2.client.O &&import&org.apache.axis2.rpc.client.RPCServiceC &&&&&&public&class&GetWSByAxis2&{ &&&&&&&&private&static&String&EndPointU &&&&&&&&private&static&String&QUrl="http://ws.apache.org/axis2"; &&&&&&&&private&QName&opAddE& &&&&&&&&public&String&WSU &&&&&&&&public&RPCServiceClient&setOption()&throws&AxisFault &&&&&&&&{ &&&&&&&&&&&&RPCServiceClient&serviceClient&=&new&RPCServiceClient(); &&&&&&&&&&&&Options&options&=&serviceClient.getOptions(); &&&&&&&&&&&&EndpointReference&targetEPR&=&new&EndpointReference(WSUrl); &&&&&&&&&&&&options.setTo(targetEPR); &&&&&&&&&&&&return&serviceC &&&&&&&&} &&&&&&&& &&&&&&&&public&QName&getQname(String&Option){ &&&&&&&&&&&& &&&&&&&&&&&&return&new&QName&(QUrl,Option); &&&&&&&&} &&&//返回String&&&&&&&&&public&String&getStr(String&Option)&throws&AxisFault &&&&&&&&{ &&&&&&&&&&&&RPCServiceClient&serviceClient&=this.setOption();& &&&&&&& &&&&&&&&&&&&opAddEntry&=this.getQname(Option); &&&&&&&& &&&&&&&&&&&String&str&=&(String)&serviceClient.invokeBlocking(opAddEntry,& &&&&&&&&&&&&&&&&&&&&&&&&&&&&new&Object[]{},&new&Class[]{String.class&})[0]; &&&&&&&&&&&return& &&&&&&&} &&//&返回一维String数组&&&&&&&&&public&String[]&getArray(String&Option)&throws&AxisFault &&&&&&&&{ &&&&&&&&&&&&RPCServiceClient&serviceClient&=this.setOption();& &&&&&&& &&&&&&&&&&&&opAddEntry&=this.getQname(Option); &&&&&&&& &&&&&&&&&&&String[]&strArray&=&(String[])&serviceClient.invokeBlocking(opAddEntry,& &&&&&&&&&&&&&&&&&&&&&&&&&&&&new&Object[]{},&new&Class[]{String[].class&})[0]; &&&&&&&&&&&return&strA &&&&&&&} &&&&&&&&//从WebService中返回一个对象的实例&&&&&&&&public&Object&getObject(String&Option,Object&o)&throws&AxisFault &&&&&&&{& &&&&&&&&&&RPCServiceClient&serviceClient&=this.setOption();& &&&&&&&&&&&QName&qname=this.getQname(Option); &&&&&&&&&&&Object&object&=&serviceClient.invokeBlocking(qname,&new&Object[]{},new&Class[]{o.getClass()})[0]; &&&&&&&&&&&return& &&&&&&&} &&&&&&& &&/////////////////////////////////////////&&&&&&&读者可以自己封装数据类型,如int,byte,float等数据类型&&&}&&Java代码&package&MZ.GetWebS&&import&javax.xml.namespace.QN&&&&import&org.apache.axis2.AxisF&&import&org.apache.axis2.addressing.EndpointR&&import&org.apache.axis2.client.O&&import&org.apache.axis2.rpc.client.RPCServiceC&&&&&&public&class&GetWSByAxis2&{&&&&&&&&private&static&String&EndPointU&&&&&&&&private&static&String&QUrl="http://ws.apache.org/axis2";&&&&&&&&private&QName&opAddE&&&&&&&&&public&String&WSU&&&&&&&&public&RPCServiceClient&setOption()&throws&AxisFault&&&&&&&&{&&&&&&&&&&&&RPCServiceClient&serviceClient&=&new&RPCServiceClient();&&&&&&&&&&&&Options&options&=&serviceClient.getOptions();&&&&&&&&&&&&EndpointReference&targetEPR&=&new&EndpointReference(WSUrl);&&&&&&&&&&&&options.setTo(targetEPR);&&&&&&&&&&&&return&serviceC&&&&&&&&}&&&&&&&&&&&&&&&&public&QName&getQname(String&Option){&&&&&&&&&&&&&&&&&&&&&&&&return&new&QName&(QUrl,Option);&&&&&&&&}&&&//返回String&&&&&&&&public&String&getStr(String&Option)&throws&AxisFault&&&&&&&&{&&&&&&&&&&&&RPCServiceClient&serviceClient&=this.setOption();&&&&&&&&&&&&&&&&&&&&opAddEntry&=this.getQname(Option);&&&&&&&&&&&&&&&&&&&String&str&=&(String)&serviceClient.invokeBlocking(opAddEntry,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&new&Object[]{},&new&Class[]{String.class&})[0];&&&&&&&&&&&return&&&&&&&&}&&//&返回一维String数组&&&&&&&&public&String[]&getArray(String&Option)&throws&AxisFault&&&&&&&&{&&&&&&&&&&&&RPCServiceClient&serviceClient&=this.setOption();&&&&&&&&&&&&&&&&&&&&opAddEntry&=this.getQname(Option);&&&&&&&&&&&&&&&&&&&String[]&strArray&=&(String[])&serviceClient.invokeBlocking(opAddEntry,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&new&Object[]{},&new&Class[]{String[].class&})[0];&&&&&&&&&&&return&strA&&&&&&&}&&&&&&&&//从WebService中返回一个对象的实例&&&&&&&public&Object&getObject(String&Option,Object&o)&throws&AxisFault&&&&&&&{&&&&&&&&&&&RPCServiceClient&serviceClient&=this.setOption();&&&&&&&&&&&&QName&qname=this.getQname(Option);&&&&&&&&&&&Object&object&=&serviceClient.invokeBlocking(qname,&new&Object[]{},new&Class[]{o.getClass()})[0];&&&&&&&&&&&return&&&&&&&&}&&&&&&&&&/////////////////////////////////////////&&&&&&&读者可以自己封装数据类型,如int,byte,float等数据类型&&}&&客户端调用方法:&Java代码&MZ.GetWebService.GetWSByAxis2&ws=new&MZ.GetWebService.GetWSByAxis2(); &&ws.WSUrl="http://localhost:8989/axis2/services/HelloWorld"; &&HelloWorld&hello=&(HelloWorld)ws.getObject("getName",&HelloWorld.class); &&&&&&&&&&&&&& &&&&&&&&&&&&& &&&System.out.println(hello.getName("zhangjin"));&&Java代码&MZ.GetWebService.GetWSByAxis2&ws=new&MZ.GetWebService.GetWSByAxis2();&&ws.WSUrl="http://localhost:8989/axis2/services/HelloWorld";&&HelloWorld&hello=&(HelloWorld)ws.getObject("getName",&HelloWorld.class);&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&System.out.println(hello.getName("zhangjin"));&&2.使用service.xml发布webservice,这种方式和直接放在pojo目录中的POJO类不同。要想将MyService类发布成Web Service,需要一个services.xml文件,这个文件需要放在META-INF目录中,该文件的内容如下:&Xml代码&&service&name="HelloWorld"&&&&&&&&description&&&&&&&&&&&HelloWorld&webservice &&&&&&&/description&&&&&&&&parameter&name="ServiceClass"&&&&&&&&&&&service.HelloWorld&& &&&&&&&/parameter&&&&&&&&messageReceivers&&&&&&&&&&&&messageReceiver&mep="http://www.w3.org/2004/08/wsdl/in-out"&&&&&&&&&&&&&&class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"&/&&&&&&&&&&&&messageReceiver&mep="http://www.w3.org/2004/08/wsdl/in-only"&&&&&&&&&&&&&&class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"&/&&&&&&&&/messageReceivers&&&&/service&&&Xml代码&&service&name="HelloWorld"&&&&&&&&description&&&&&&&&&&&HelloWorld&webservice&&&&&&&/description&&&&&&&&parameter&name="ServiceClass"&&&&&&&&&&&service.HelloWorld&&&&&&&&&/parameter&&&&&&&&messageReceivers&&&&&&&&&&&&messageReceiver&mep="http://www.w3.org/2004/08/wsdl/in-out"&&&&&&&&&&&&&&class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"&/&&&&&&&&&&&&messageReceiver&mep="http://www.w3.org/2004/08/wsdl/in-only"&&&&&&&&&&&&&&class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"&/&&&&&&&&/messageReceivers&&&&/service&&&其中&service&元素用于发布Web Service,一个&service&元素只能发布一个WebService类,name属性表示WebService名,如下面的URL可以获得这个WebService的WSDL内容:&http://localhost:8080/axis2/services/myService?wsdl&& 除此之外,还有直接可以在其中制定webservice操作方法:可以这样些service.xml文件&Java代码&&service&name="HelloWorld"& &&&&&&&description& &&&&&&&&&HelloWorld&service &&&&&&&/description& &&&&&&&parameter&name="ServiceClass"& &&&&&&&&&&service.HelloWorld&& &&&&&&&/parameter& &&&&&&&operation&name="getName"& &&&&&&&&&&&messageReceiver&class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"&/& &&&&&&&/operation& &&&&&&&operation&name="add"& &&&&&&&&&&&messageReceiver &&&&&&&&&&&&&&class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"&/& &&&&&&&/operation& &&&/service&&&Java代码&service&name="HelloWorld"&&&&&&&&description&&&&&&&&&&HelloWorld&service&&&&&&&/description&&&&&&&&parameter&name="ServiceClass"&&&&&&&&&&&service.HelloWorld&&&&&&&&&/parameter&&&&&&&&operation&name="getName"&&&&&&&&&&&&messageReceiver&class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"&/&&&&&&&&/operation&&&&&&&&operation&name="add"&&&&&&&&&&&&messageReceiver&&&&&&&&&&&&&&class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"&/&&&&&&&&/operation&&&&/service&&&如果要发布多个webservice,可以在文件两段加上&serviceGroup&&service&&/service&...&service&&/service&&/serviceGroup&发布(记得关注噢)&
阅读(31737)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'java调用webservice接口方法(SOAP message、xfire、axis)',
blogAbstract:'
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 win10玩游戏卡顿掉帧 的文章

 

随机推荐