如何用axis2 client api 写j代码访问web service
wswhp
|
1#
wswhp 发表于 2008-11-17 04:30
如何用axis2 client api 写j代码访问web service
现在web service 已经发布成功
可以在浏览器里访问 类似 http://localhost:8080/services/HelloService?wsdl 现在我想写个客户端访问这个服务中的一个方法 比如 http://localhost:8080/services/HelloService/sayHello 我想用 axis2 client Api来写访问程序,但是找了半天资料不全, 请问哪位能给我个例子啊 ,或者是tutorial 入门都可以 http://localhost:8080/services/HelloService?wsdl如下 <?xml version="1.0" encoding="UTF-8" ?> - <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://test" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://test"> <wsdl:documentation>HelloService </wsdl:documentation> - <wsdl:types> - <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test"> - <xs:element name="sayHelloResponse"> - <xs:complexType> - <xs:sequence> <xs:element minOccurs="0" name="return" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name="speakRequest" /> <wsdl:message name="yellRequest" /> <wsdl:message name="sayHelloRequest" /> - <wsdl:message name="sayHelloResponse"> <wsdl:part name="parameters" element="ns:sayHelloResponse" /> </wsdl:message> - <wsdl:portType name="HelloServicePortType"> - <wsdl:operation name="speak"> <wsdl:input message="ns:speakRequest" wsaw:Action="urn:speak" /> </wsdl:operation> - <wsdl:operation name="yell"> <wsdl:input message="ns:yellRequest" wsaw:Action="urn:yell" /> </wsdl:operation> - <wsdl:operation name="sayHello"> <wsdl:input message="ns:sayHelloRequest" wsaw:Action="urn:sayHello" /> <wsdl:output message="ns:sayHelloResponse" wsaw:Action="urn:sayHelloResponse" /> </wsdl:operation> </wsdl:portType> + <wsdl:binding name="HelloServiceSoap11Binding" type="ns:HelloServicePortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> - <wsdl:operation name="speak"> <soap:operation soapAction="urn:speak" style="document" /> - <wsdl:input> <soap:body use="literal" /> </wsdl:input> </wsdl:operation> - <wsdl:operation name="yell"> <soap:operation soapAction="urn:yell" style="document" /> - <wsdl:input> <soap:body use="literal" /> </wsdl:input> </wsdl:operation> - <wsdl:operation name="sayHello"> <soap:operation soapAction="urn:sayHello" style="document" /> - <wsdl:input> <soap:body use="literal" /> </wsdl:input> - <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> + <wsdl:binding name="HelloServiceSoap12Binding" type="ns:HelloServicePortType"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> - <wsdl:operation name="speak"> <soap12:operation soapAction="urn:speak" style="document" /> - <wsdl:input> <soap12:body use="literal" /> </wsdl:input> </wsdl:operation> - <wsdl:operation name="yell"> <soap12:operation soapAction="urn:yell" style="document" /> - <wsdl:input> <soap12:body use="literal" /> </wsdl:input> </wsdl:operation> - <wsdl:operation name="sayHello"> <soap12:operation soapAction="urn:sayHello" style="document" /> - <wsdl:input> <soap12:body use="literal" /> </wsdl:input> - <wsdl:output> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> + <wsdl:binding name="HelloServiceHttpBinding" type="ns:HelloServicePortType"> <http:binding verb="POST" /> - <wsdl:operation name="speak"> <http:operation location="HelloService/speak" /> - <wsdl:input> <mime:content type="text/xml" part="speak" /> </wsdl:input> </wsdl:operation> - <wsdl:operation name="yell"> <http:operation location="HelloService/yell" /> - <wsdl:input> <mime:content type="text/xml" part="yell" /> </wsdl:input> </wsdl:operation> - <wsdl:operation name="sayHello"> <http:operation location="HelloService/sayHello" /> - <wsdl:input> <mime:content type="text/xml" part="sayHello" /> </wsdl:input> - <wsdl:output> <mime:content type="text/xml" part="sayHello" /> </wsdl:output> </wsdl:operation> </wsdl:binding> + <wsdl:service name="HelloService"> - <wsdl:port name="HelloServiceHttpSoap11Endpoint" binding="ns:HelloServiceSoap11Binding"> <soap:address location="http://localhost:80/services/HelloService.HelloServiceHttpSoap11Endpoint/" /> </wsdl:port> - <wsdl:port name="HelloServiceHttpSoap12Endpoint" binding="ns:HelloServiceSoap12Binding"> <soap12:address location="http://localhost:80/services/HelloService.HelloServiceHttpSoap12Endpoint/" /> </wsdl:port> - <wsdl:port name="HelloServiceHttpEndpoint" binding="ns:HelloServiceHttpBinding"> <http:address location="http://localhost:80/services/HelloService.HelloServiceHttpEndpoint/" /> </wsdl:port> </wsdl:service> </wsdl:definitions> |