导航:首页 > 版本升级 > wsdl文件怎么使用

wsdl文件怎么使用

发布时间:2024-09-07 23:11:32

⑴ 如何打开wsdl文件

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

1,直接AXIS调用远程的web service,直接调用模式如下:
import java.util.Date;
import java.text.DateFormat;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import java.lang.Integer;
import javax.xml.rpc.ParameterMode;

public class caClient {
public static void main(String[] args) {
try {
String endpoint = "http://localhost:8080/ca3/services/caSynrochnized?wsdl";
//直接引用远程的wsdl文件
//以下都是套路
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName("addUser");//WSDL里面描述的接口名称
call.addParameter("userName", org.apache.axis.encoding.XMLType.XSD_DATE,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型
String temp = "测试人员";
String result = (String)call.invoke(new Object[]{temp});
//给方法传递参数,并且调用方法
System.out.println("result is "+result);
}
catch (Exception e) {
System.err.println(e.toString());
}
}
}

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

public class caService{
public static String getService(String user) {
URL url = null;
try {
url=new URL("http://192.168.0.100:8080/ca3/services/caSynrochnized");
} catch (MalformedURLException mue) {
return mue.getMessage();
}
// This is the main SOAP object
Call soapCall = new Call();
// Use SOAP encoding
soapCall.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
// This is the remote object we're asking for the price
soapCall.setTargetObjectURI("urn:xmethods-caSynrochnized");
// This is the name of the method on the above object
soapCall.setMethodName("getUser");
// We need to send the ISBN number as an input parameter to the method
Vector soapParams = new Vector();
// name, type, value, encoding style
Parameter isbnParam = new Parameter("userName", String.class, user, null);
soapParams.addElement(isbnParam);
soapCall.setParams(soapParams);
try {
// Invoke the remote method on the object
Response soapResponse = soapCall.invoke(url,"");
// Check to see if there is an error, return "N/A"
if (soapResponse.generatedFault()) {
Fault fault = soapResponse.getFault();
String f = fault.getFaultString();
return f;
} else {
// read result
Parameter soapResult = soapResponse.getReturnValue ();
// get a string from the result
return soapResult.getValue().toString();
}
} catch (SOAPException se) {
return se.getMessage();
}
}
}

阅读全文

与wsdl文件怎么使用相关的资料

热点内容
樱花校园模拟器怎么和数据库连接 浏览:694
红酒包装盒设计教程 浏览:534
为什么编程这么难入坑 浏览:786
java代码图片路径 浏览:474
达内学安卓怎么样 浏览:300
word2010并排两个表格 浏览:284
酷派安卓如何升级版本 浏览:684
linuxidl文件 浏览:730
校园网站问题及如何解决网站问题 浏览:256
华为鸿蒙录音文件在哪个文件夹 浏览:900
psraw预设在哪个文件 浏览:385
文件名后面的zip是什么意思 浏览:722
jsutf8gbk 浏览:261
苹果5怎样换屏幕图标 浏览:452
微信上晒照片有危险吗 浏览:499
绕过改密码登录密码登录密码登录密码登录 浏览:450
风暴英雄当前版本最强 浏览:104
余姚数控编程培训哪里专业 浏览:419
qq空间66版本下载 浏览:908
有一款看美剧的app是什么 浏览:397

友情链接