如何打开wsdl文件

时间:2015.11.29 发布人:vxkew2791

如何打开wsdl文件

已解决问题

谷歌vxkew2791用户在2015.11.29提交了关于“夜行书生如何打开wsdl文件”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-03-16T03:03:03。希望大家能够帮助她。

详细问题描述及疑问:期待您的答案,感谢你,我会记得你对我的好的 !

希望以下的回答,能够帮助你。

第1个回答

用户名:Losttenbe医措此其业解某断化岩r  

webservice的发来自布一般都是使用WSDL(webservicedescriptivelanguage)文件的样式来发布的,在WSDL文件里面,包含这个webservice暴露在外面可供使用的接口。
注意,以下的代码并没有经过真正的测试,只是说明这些情况,不同版本的Axis相差很大,最好以apach问答e网站上的例子为准,这里仅仅用于说明其基本用法。

1,直接AXIS调用远程的webservice,直接调用模湖者个帝岁式如下:
impor唱火tj**a.***.date;
importjava.***.dateformat;
importorg.***短视委附带回响镇.client.call;
importorg.雷善写干氧农供定善映***.client.service;
importj**ax.***.qname;
鱼针处此极importj**a.**绿*.integer;
importj**ax.***.parametermode;

publicclasscaClient{
public策景财班巴律水室查staticvoidmain送(String[]args){
try{
Strin识华gendpoint钱永调宣="http:/稳粒洲/localhost:8080/ca3/services/caSynrochnized?w快sdl";
//直接引用远程尔慢汽调己下的wsdl文件
//以下都是套路
Serviceservice=newService();
Callcall=(Call)***.createcall();
***.settarge附较易互铁衣点济坚列技tendpointaddress(end肥批况伤政局point);
***.setoperationname("a初研ddUser");//WSDL里面描述的接口名称
***.addparameter("userName",org.府略宁团责批***.encoding.xmltype.xsd_DATE,
j**ax.***.parametermode.in);//接口的参数
***.setreturntype(org.***.encoding.xmltype.xsd_STRING);//设置返回类型
Stringtemp="测试人员";
Stringresult=(String)***.invoke(newObject[]{temp});
//给方法传递参数,并且调用方法
system.***.println("resultis"+result);
}
catch(Exceptione){
system.***.println(***.tostring());
}
}
}

2,直接SOAP调用远程的webservice,这种模式很少用,但是网络上有人贴出来,也转过来:
importorg.***.soap.util.xml.*;
importorg.***.soap.*;
importorg.***.rpc.*;
import***.io.*;
import***.net.*;
importj**a.***.vector;

publicclasscaService{
publicstaticStringgetService(Stringuser){
URLurl=**ll;
try{
url=newURL("http://192.168.0.100:8080/ca3/services/caSynrochnized");
}catch(MalformedURLExceptionmue){
return***.getmessage();
}
//ThisisthemainSOAPobject
CallsoapCall=newCall();
//UseSOAPencoding
***.setencodingstyleuri(***.ns_URI_SOAP_ENC);
//Thisistheremoteobjectwe'reaskingfortheprice
***.settargetobjecturi("urn:xmethods-caSynrochnized");
//Thisisthenameofthemethodonthe**veobject
***.setmethodname("getUser");
//WeneedtosendtheISBN**mberasaninputparametertothemethod
VectorsoapParams=newVector();
//name,type,value,encodingstyle
ParameterisbnParam=newParameter("userName",***.class,user,**ll);
***.addelement(isbnParam);
***.setparams(soapParams);
try{
//Invoketheremotemethodontheobject
ResponsesoapResponse=***.invoke(url,"");
//Checktoseeifthereisanerror,return"N/A"
if(***.generatedfault()){
Faultfault=***.getfault();
Stringf=***.get***string();
returnf;
}else{
//readresult
ParametersoapResult=***.getreturnvalue();
//getastringfromtheresult
return***.getvalue().toString();
}
}catch(SOAPExceptionse){
return***.getmessage();
}
}
}