通过所给的xml文件来远程调用service服务方法
来源:互联网 发布:爱知日语培训班价格 编辑:程序博客网 时间:2024/05/17 21:39
所给的XML文档
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://localhost:8081/axis/services/testaxis" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8081/axis/services/testaxis" xmlns:intf="http://localhost:8081/axis/services/testaxis" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:message name="getUserResponse">
<wsdl:part name="getUserReturn" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="getUserRequest">
<wsdl:part name="name" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="authenticateResponse">
<wsdl:part name="authenticateReturn" type="xsd:dateTime"/>
</wsdl:message>
<wsdl:message name="authenticateRequest">
</wsdl:message>
<wsdl:portType name="TestAxis">
<wsdl:operation name="authenticate">
<wsdl:input message="impl:authenticateRequest" name="authenticateRequest"/>
<wsdl:output message="impl:authenticateResponse" name="authenticateResponse"/>
</wsdl:operation>
<wsdl:operation name="getUser" parameterOrder="name">
<wsdl:input message="impl:getUserRequest" name="getUserRequest"/>
<wsdl:output message="impl:getUserResponse" name="getUserResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="testaxisSoapBinding" type="impl:TestAxis">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="authenticate">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="authenticateRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://service" use="encoded"/>
</wsdl:input>
<wsdl:output name="authenticateResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8081/axis/services/testaxis" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getUser">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getUserRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://service" use="encoded"/>
</wsdl:input>
<wsdl:output name="getUserResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8081/axis/services/testaxis" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TestAxisService">
<wsdl:port binding="impl:testaxisSoapBinding" name="testaxis">
<wsdlsoap:address location="http://192.168.4.55:8081/axis/services/testaxis"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
方法的调用
package com.yysoft.chen;
import java.rmi.RemoteException;
import java.util.Date;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.ServiceFactory;
import org.apache.tools.ant.types.resolver.ApacheCatalog;
public class TextService {
public static void main(String[] args) {
testaxiss();
}
public static void testaxis(){
try {
QName servicename=new QName("http://192.168.4.55:8081/axis/services/testaxis","TestAxisService");
Service service=ServiceFactory.newInstance().createService(servicename);
Call call=service.createCall();
call.setTargetEndpointAddress("http://192.168.4.55:8081/axis/services/testaxis?wsdl");
QName operationname=new QName("http://localhost:8081/axis/services/testaxis","authenticate");
call.setOperationName(operationname);
QName returnname=new QName("http://www.w3.org/2001/XMLSchema","dateTime");
call.setReturnType(returnname, java.util.Date.class);
Date d= (Date) call.invoke(new Object[]{});
System.out.println(d.toLocaleString());
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void testaxiss(){
try {
QName servicename=new QName("http://192.168.4.55:8081/axis/services/testaxis","TestAxisService");
Service service=ServiceFactory.newInstance().createService(servicename);
Call call=service.createCall();
call.setTargetEndpointAddress("http://192.168.4.55:8081/axis/services/testaxis?wsdl");
QName operationname=new QName("http://localhost:8081/axis/services/testaxis","getUser");
call.setOperationName(operationname);
QName namename=new QName("http://schemas.xmlsoap.org/soap/encoding/","name");
call.addParameter("name", namename, javax.xml.rpc.ParameterMode.IN);
QName returnname=new QName("http://schemas.xmlsoap.org/soap/encoding/","string");
call.setReturnType(returnname, String.class); //将设好的返回类型装载入call中
String version=(String)call.invoke(new Object[]{"fffsad"});
System.out.println(version);
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void version(){
try {
//Qname("名称空间","对应名称");
//设置服务名及对应的名称空间
QName servicename=new QName("http://localhost:8081/axis/services/Version","VersionService");
//根据对应的名称空间和服务名称创建一个服务
Service service=ServiceFactory.newInstance().createService(servicename);
//通过service创建一个call(调用方法)
Call call=service.createCall();
call.setTargetEndpointAddress("http://192.168.4.55:8081/axis/services/Version?wsdl");
//设置方法名及对应的名称空间
QName operationname=new QName("http://localhost:8081/axis/services/Version","getVersion");
call.setOperationName(operationname); //将设好的方法装载入call中
//设置返回类型及对应的名称空间
QName returnname=new QName("http://www.w3.org/2001/XMLSchema","string");
call.setReturnType(returnname, String.class); //将设好的返回类型装载入call中
String version=(String)call.invoke(new Object[]{});
System.out.println(version);
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
- 通过所给的xml文件来远程调用service服务方法
- Android Service 调用远程服务中的方法
- Android -- service的开启方式, start开启和绑定开启服务,调用服务的的方法, aidl调用远程服务
- Java如何通过WSDL文件来调用这些web service
- Java如何通过WSDL文件来调用这些web service
- Java如何通过WSDL文件来调用这些web service
- Android通过广播接收者调用服务(service)内方法
- android,aidl,绑定远程服务,调用远程服务的方法
- Web服务入门之三:通过XFire调用远程Web Service,实现QQ在线服务功能
- 通过Binder调用Service内的方法
- 通过大型xml文件来提供数据服务
- bbossgroups 2.0-RC 通过JGroups来实现集群节点间远程服务调用,或者多服务器之间远程服务调用
- Service的远程调用
- Service的远程调用
- Service的远程调用
- Service的远程调用
- service的远程调用
- 通过get或post的方式来调用web service
- 中国办公室的22条潜规则
- .NET笔试题(@20081022)
- .NET页面之间传值的方法总结
- 在windows xp上删除oracle9i方法
- C#中的异常处理
- 通过所给的xml文件来远程调用service服务方法
- JSP乱码解决之终极篇
- 没什么明显变化【28周】
- MFC应用程序中处理消息的顺序【转】
- 完成端口(I/O completion):
- 3dsmax5/3dmax6/3dmax7/3dmax8快捷键大全
- Project Note2
- 使用 JDOM 读取和写入 XML 文件
- 完成端口的一个例子