客户端调用Webservice例子(Axis)
import org.apache.axis.client.Call;
? // <? xml version="1.0" encoding="UTF-8" ?>
-
<
wsdl:definitions targetNamespace
="
http://172.25.165.45:8080/spc/services/spcRealTimeMonitorService
"
xmlns:apachesoap
="
http://xml.apache.org/xml-soap
"
xmlns:impl
="
http://172.25.165.45:8080/spc/services/spcRealTimeMonitorService
"
xmlns:intf
="
http://172.25.165.45:8080/spc/services/spcRealTimeMonitorService
"
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? -->
-
<
wsdl:message name
="
getStatusResponse
" >
?
<
wsdl:part
name
="
getStatusReturn
"
type
="
xsd:string
" />
?
</
wsdl:message
>
-
<
wsdl:message name
="
getStatusRequest
" >
?
<
wsdl:part
name
="
id
"
type
="
xsd:int
" />
?
<
wsdl:part
name
="
groupType
"
type
="
xsd:int
" />
?
</
wsdl:message
>
-
<
wsdl:message name
="
spcDownloadResponse
" >
?
<
wsdl:part
name
="
spcDownloadReturn
"
type
="
xsd:string
" />
?
</
wsdl:message
>
-
<
wsdl:message name
="
operateMonitorBTRequest
" >
?
<
wsdl:part
name
="
id
"
type
="
xsd:int
" />
?
<
wsdl:part
name
="
status
"
type
="
xsd:string
" />
?
<
wsdl:part
name
="
operate
"
type
="
xsd:string
" />
?
</
wsdl:message
>
?
<
wsdl:message
name
="
operateMonitorBBResponse
" />
?
<
wsdl:message
name
="
spcDownloadRequest
" />
-
<
wsdl:message name
="
operateMonitorBBRequest
" >
?
<
wsdl:part
name
="
id
"
type
="
xsd:int
" />
?
<
wsdl:part
name
="
status
"
type
="
xsd:string
" />
?
<
wsdl:part
name
="
operate
"
type
="
xsd:string
" />
?
</
wsdl:message
>
?
<
wsdl:message
name
="
operateMonitorBTResponse
" />
-
<
wsdl:portType name
="
JaxRpcSpcRealTimeMonitorService
" >
-
<
wsdl:operation name
="
operateMonitorBT
"
parameterOrder
="
id status operate
" >
?
<
wsdl:input
message
="
impl:operateMonitorBTRequest
"
name
="
operateMonitorBTRequest
" />
?
<
wsdl:output
message
="
impl:operateMonitorBTResponse
"
name
="
operateMonitorBTResponse
" />
?
</
wsdl:operation
>
-
<
wsdl:operation name
="
operateMonitorBB
"
parameterOrder
="
id status operate
" >
?
<
wsdl:input
message
="
impl:operateMonitorBBRequest
"
name
="
operateMonitorBBRequest
" />
?
<
wsdl:output
message
="
impl:operateMonitorBBResponse
"
name
="
operateMonitorBBResponse
" />
?
</
wsdl:operation
>
-
<
wsdl:operation name
="
spcDownload
" >
?
<
wsdl:input
message
="
impl:spcDownloadRequest
"
name
="
spcDownloadRequest
" />
?
<
wsdl:output
message
="
impl:spcDownloadResponse
"
name
="
spcDownloadResponse
" />
?
</
wsdl:operation
>
-
<
wsdl:operation name
="
getStatus
"
parameterOrder
="
id groupType
" >
?
<
wsdl:input
message
="
impl:getStatusRequest
"
name
="
getStatusRequest
" />
?
<
wsdl:output
message
="
impl:getStatusResponse
"
name
="
getStatusResponse
" />
?
</
wsdl:operation
>
?
</
wsdl:portType
>
-
<
wsdl:binding name
="
spcRealTimeMonitorServiceSoapBinding
"
type
="
impl:JaxRpcSpcRealTimeMonitorService
" >
?
<
wsdlsoap:binding
style
="
rpc
"
transport
="
http://schemas.xmlsoap.org/soap/http
" />
-
<
wsdl:operation name
="
operateMonitorBT
" >
?
<
wsdlsoap:operation
soapAction
=" " />
-
<
wsdl:input name
="
operateMonitorBTRequest
" >
?
<
wsdlsoap:body
encodingStyle
="
http://schemas.xmlsoap.org/soap/encoding/
"
namespace
="
http://webservice.remote.server.spc.scion.sanminasci.com
"
use
="
encoded
" />
?
</
wsdl:input
>
-
<
wsdl:output name
="
operateMonitorBTResponse
" >
?
<
wsdlsoap:body
encodingStyle
="
http://schemas.xmlsoap.org/soap/encoding/
"
namespace
="
http://172.25.165.45:8080/spc/services/spcRealTimeMonitorService
"
use
="
encoded
" />
?
</
wsdl:output
>
?
</
wsdl:operation
>
-
<
wsdl:operation name
="
operateMonitorBB
" >
?
<
wsdlsoap:operation
soapAction
=" " />
-
<
wsdl:input name
="
operateMonitorBBRequest
" >
?
<
wsdlsoap:body
encodingStyle
="
http://schemas.xmlsoap.org/soap/encoding/
"
namespace
="
http://webservice.remote.server.spc.scion.sanminasci.com
"
use
="
encoded
" />
?
</
wsdl:input
>
-
<
wsdl:output name
="
operateMonitorBBResponse
" >
?
<
wsdlsoap:body
encodingStyle
="
http://schemas.xmlsoap.org/soap/encoding/
"
namespace
="
http://172.25.165.45:8080/spc/services/spcRealTimeMonitorService
"
use
="
encoded
" />
?
</
wsdl:output
>
?
</
wsdl:operation
>
-
<
wsdl:operation name
="
spcDownload
" >
?
<
wsdlsoap:operation
soapAction
=" " />
-
<
wsdl:input name
="
spcDownloadRequest
" >
?
<
wsdlsoap:body
encodingStyle
="
http://schemas.xmlsoap.org/soap/encoding/
"
namespace
="
http://webservice.remote.server.spc.scion.sanminasci.com
"
use
="
encoded
" />
?
</
wsdl:input
>
-
<
wsdl:output name
="
spcDownloadResponse
" >
?
<
wsdlsoap:body
encodingStyle
="
http://schemas.xmlsoap.org/soap/encoding/
"
namespace
="
http://172.25.165.45:8080/spc/services/spcRealTimeMonitorService
"
use
="
encoded
" />
?
</
wsdl:output
>
?
</
wsdl:operation
>
-
<
wsdl:operation name
="
getStatus
" >
?
<
wsdlsoap:operation
soapAction
=" " />
-
<
wsdl:input name
="
getStatusRequest
" >
?
<
wsdlsoap:body
encodingStyle
="
http://schemas.xmlsoap.org/soap/encoding/
"
namespace
="
http://webservice.remote.server.spc.scion.sanminasci.com
"
use
="
encoded
" />
?
</
wsdl:input
>
-
<
wsdl:output name
="
getStatusResponse
" >
?
<
wsdlsoap:body
encodingStyle
="
http://schemas.xmlsoap.org/soap/encoding/
"
namespace
="
http://172.25.165.45:8080/spc/services/spcRealTimeMonitorService
"
use
="
encoded
" />
?
</
wsdl:output
>
?
</
wsdl:operation
>
?
</
wsdl:binding
>
-
<
wsdl:service name
="
JaxRpcSpcRealTimeMonitorServiceService
" >
-
<
wsdl:port binding
="
impl:spcRealTimeMonitorServiceSoapBinding
"
name
="
spcRealTimeMonitorService
" >
?
<
wsdlsoap:address
location
="
http://172.25.165.45:8080/spc/services/spcRealTimeMonitorService
" />
?
</
wsdl:port
>
?
</
wsdl:service
>
?
</
wsdl:definitions
>
=========================================
import org.apache.axis.client.Call;
import org.apache.axis.client.Service; import org.apache.axis.encoding.ser.BeanDeserializerFactory; import org.apache.axis.encoding.ser.BeanSerializerFactory; import com.mycompany.MonitoredObjectTo; ??? String ip="localhost"; ??? ??? try{ ??? ??? ??? String endpoint = "http://"+ip+":8080/test/services/spcMonitoredObjectService"; ??? ??? ??? System.out.println( endpoint? ); ??? ??????? Service? service = new Service(); ??? ??????? Call???? call??? = (Call) service.createCall(); ??? ??????? call.setTargetEndpointAddress( new java.net.URL(endpoint) ); ??? ??????? call.setOperationName("getAllSpcMonitoredObject"); ??? ??? ??? QName qn = new QName("urn:myUrn","MonitoredObjectTo"); ??? ??? ??? call.registerTypeMapping(MonitoredObjectTo.class,qn,new BeanSerializerFactory(MonitoredObjectTo.class,qn),new BeanDeserializerFactory(MonitoredObjectTo.class,qn)); ??? ?????? / ??? ??????? Object[] object=(Object[])? call.invoke( new Object[] {} ); ??? ??? ??? if (object !=null){ ??? ??? ??? ??? for(int i=0;i<object.length;i++){ ??? ??? ??? ??? ??? MonitoredObjectTo monitoredObject= (MonitoredObjectTo) object[i]; ??? ??? ??? ??? ??? System.out.println( monitoredObject.getObjectName() ); ??? ??? ??? ??? } ??? ??? ??? } ??? ??? }catch(Exception e){ ??? ??? ??? e.printStackTrace(); ??? ??? }finally{ ??? ??? ??? ??? ??? }
带参数例子
??? ??? String endpoint = "http://172.25.165.1:8080/xxx/services/serverInfo";
??? ??? Service service = new Service(); ??? ??? Call call = null; ??? ??? call = (Call) service.createCall(); ??? ??? QName qn = new QName("urn:xxxx","MachineMap"); ??? ??? call.setTargetEndpointAddress(new java.net.URL(endpoint)); ??? ??? call.registerTypeMapping(MachineMap.class,new BeanSerializerFactory(MachineMap.class,new BeanDeserializerFactory(MachineMap.class,qn)); ??? ??? call.setOperationName(new QName(endpoint,"getMachineByProgramName")); ??? ??? call.setReturnType(call.getReturnType());?? ??? ??? System.out.println( ((Object[])call.invoke(new Object[] {" XXX "})).length); //XXX为输入参数
另外
浏览器如何罗列webservice 数据 ,参考格式
http://yourmachine:port/webapplication/services/yourWebservice?method=methodName
http://172.25.165.9:8080/myApplication/services/EmailService?method=getAllEmail
带参数的URL查询
http://172.25.165.1:8080/XXXX/services/serverInfo?method=getMachineByProgramName&programName=XXX
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- macos – Bash:如何将参数与if语句进行比较?
- Angular 2.0.0 Metadata_resolver奇怪的行为
- VIM – 将多个文件中的行合并为单个文件
- bash – 从/ proc / stat计算CPU使用率
- Bootstrap table使用方法汇总
- 如何让Scala导入在IntelliJ IDEA中使用Play框架?
- amazon-web-services – 将AWS SAM Local与docker中的dyna
- angularjs – Ionic / Angular JS – 从Reverse Geolocatio
- Angular 4.x ngModel 双向绑定原理揭秘
- Vim支架和分号highliting