业务需求需要实现web service的方法能返回多个返回值,查阅了下axis的user guilde,实现起来其实很简单.
axis里面有多个类型的持有类比如StringHolder类等,我们只需要把传入的参数改为对应类型的持有类就可以了.
下面是我的例子:
实现类
public class NumwireserviceforCRMSoapBindingImpl implements com.geosoft.numwire.webservice.server.toCRM.NumwireServiceForCRM{
public int asiainfo__ResQueryCustomerId(java.lang.String in0, javax.xml.rpc.holders.StringHolder in1) throws java.rmi.RemoteException {
in1.value="1212121";
return -3;
}
}
wsdl文档:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:numwireservice" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:numwireservice" xmlns:intf="urn:numwireservice" 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="asiainfo__ResQueryCustomerIdRequest">
<wsdl:part name="in0" type="soapenc:string"/>
<wsdl:part name="in1" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="asiainfo__ResQueryCustomerIdResponse">
<wsdl:part name="asiainfo__ResQueryCustomerIdReturn" type="xsd:int"/>
<wsdl:part name="in1" type="soapenc:string"/>
</wsdl:message>
<wsdl:portType name="NumwireServiceForCRM">
<wsdl:operation name="asiainfo__ResQueryCustomerId" parameterOrder="in0 in1">
<wsdl:input message="impl:asiainfo__ResQueryCustomerIdRequest" name="asiainfo__ResQueryCustomerIdRequest"/>
<wsdl:output message="impl:asiainfo__ResQueryCustomerIdResponse" name="asiainfo__ResQueryCustomerIdResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="numwireserviceforCRMSoapBinding" type="impl:NumwireServiceForCRM">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="asiainfo__ResQueryCustomerId">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="asiainfo__ResQueryCustomerIdRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:numwireservice" use="encoded"/>
</wsdl:input>
<wsdl:output name="asiainfo__ResQueryCustomerIdResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:numwireservice" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NumwireServiceForCRMService">
<wsdl:port binding="impl:numwireserviceforCRMSoapBinding" name="numwireserviceforCRM">
<wsdlsoap:address location="http://localhost:8080/services/numwireserviceforCRM"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
调用:
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.holders.StringHolder;
import com.geosoft.numwire.webservice.server.toCRM.NumwireServiceForCRMServiceLocator;
import com.geosoft.numwire.webservice.server.toCRM.NumwireserviceforCRMSoapBindingStub;
public class TestMultyReturn {
public static void main(String[] args) {
NumwireServiceForCRMServiceLocator forCRMServiceLocator=new NumwireServiceForCRMServiceLocator();
NumwireserviceforCRMSoapBindingStub bindingStub=null;
try {
java.net.URL url=new URL("/*你的服务部署的url*/");
bindingStub=(NumwireserviceforCRMSoapBindingStub) forCRMServiceLocator.getnumwireserviceforCRM(url);
String in0="aaaaa";
StringHolder in1=new StringHolder("sdsds");
bindingStub.asiainfo__ResQueryCustomerId(in0, in1);
System.out.println(in1.value);//打印出来的是改变后的值
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
分享到:
相关推荐
webservices-api-2.2.jar.zip webservices-extra-2.2.jar.zip webservices-extra-api-2.2.jar.zip webservices-rt-1.2.jar.zip webservices-tools-2.2.0-4.jar.zip 如果还需要其他jar包,请留言留邮箱,如果我有,就...
1、利用SoapExtension,SoapExtensionAttribute,实现Soap自定义Attribute(标签)扩展类。 2、利用SoapHeader应用Soap扩展。 3、在写WebService时只需加认证标签,客户端调用时传入SoapHeader,即可完成认证。 4、...
dubbo-rpc-webservice-2.8.4 dubbo-rpc-webservice-2.8.4
webService-xfire入门 webService-xfire入门
webservice-CXF-spring 实现server+client
2、webservice--常用注解1
webservice-java_soap.pdf,webservice-java_soap.pdf
webservice-client-call axis
和之前webservice-service-demo.rar对应,对webservice-service1-demo中内容打包后,如何使用webservice的一个demo
使用eclipse导入项目,既可使用。 【webservice----xfire 快速入门代码实训】----<下载不扣分,回帖加1分,欢迎下载,童叟无欺>
webservice-jboss-tutorial.zip
webservice apache-cxf-2.3.5
EOS发布WebService-服务端
webservice-cxf里面实现了网上写的一些代码,打包,可以直接作为demo使用
silverlight-通过-WebService-连接数据库.doc
一个WebService-axis小Demo,保证可以运行
JAX-WS一个简单的java-ws webservice 例子是用myeclipse配置生成的,还行吧。
下载到你指定的路径,解开压缩包后,在文件夹下直接打开 01.html 文件即可,内容非常详细,并且所有代码均能过。
WebService-CXF.ppt
webService-Axis-tomcat发布教程.docx