wsdl内容
1、type 用来定义访问的类型(也就是定义的schema)
2、message:soap
3、portType:指定服务器的接口,并且通过operation绑定相应的in和out的消息(in表示参数,out表示返回值)
4、binding:指定传递小时所使用的格式
5、service:指定服务所发布的名称
下面是一个wsdl文件:
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://liyang.yinhai.com/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
name="IMyserviceImplService"
targetNamespace="http://liyang.yinhai.com/"> <wsdl:types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://liyang.yinhai.com/"
elementFormDefault="unqualified"
targetNamespace="http://liyang.yinhai.com/" version="1.0"> <xs:element name="add" type="tns:add"/> <xs:element name="addResponse" type="tns:addResponse"/> <xs:element name="minus" type="tns:minus"/> <xs:element name="minusResponse" type="tns:minusResponse"/> <xs:complexType name="add"> <xs:sequence> <xs:element name="arg0" type="xs:int"/> <xs:element name="arg1" type="xs:int"/> </xs:sequence> </xs:complexType> <xs:complexType name="addResponse"> <xs:sequence> <xs:element name="return" type="xs:int"/> </xs:sequence> </xs:complexType> <xs:complexType name="minus"> <xs:sequence> <xs:element name="arg0" type="xs:int"/> <xs:element name="arg1" type="xs:int"/> </xs:sequence> </xs:complexType> <xs:complexType name="minusResponse"> <xs:sequence> <xs:element name="return" type="xs:int"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:message name="add"> <wsdl:part element="tns:add" name="parameters"></wsdl:part> </wsdl:message> <wsdl:message name="minusResponse"> <wsdl:part element="tns:minusResponse" name="parameters"></wsdl:part> </wsdl:message> <wsdl:message name="minus"> <wsdl:part element="tns:minus" name="parameters"></wsdl:part> </wsdl:message> <wsdl:message name="addResponse"> <wsdl:part element="tns:addResponse" name="parameters"></wsdl:part> </wsdl:message> <wsdl:portType name="IMyservice"> <wsdl:operation name="add"> <wsdl:input message="tns:add" name="add"></wsdl:input> <wsdl:output message="tns:addResponse" name="addResponse"></wsdl:output> </wsdl:operation> <wsdl:operation name="minus"> <wsdl:input message="tns:minus" name="minus"></wsdl:input> <wsdl:output message="tns:minusResponse" name="minusResponse"></wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="IMyserviceImplServiceSoapBinding" type="tns:IMyservice"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="add"> <soap:operation soapAction="" style="document"/> <wsdl:input name="add"> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="addResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="minus"> <soap:operation soapAction="" style="document"/> <wsdl:input name="minus"> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="minusResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="IMyserviceImplService"> <wsdl:port binding="tns:IMyserviceImplServiceSoapBinding" name="IMyserviceImplPort"> <soap:address location="http://127.0.0.1:8888/ns"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
当你不想让soap传递参数为agr0,agr1这些可以在接口那按下面设置
@WebResult(name="addresult")//这里的定义就是保证上面那段wsdl中,schema部分的规范,这里代替的是return public int add(@WebParam(name="a") int a, @WebParam(name="b") int b); //这2个代替的是2个参数,agr1和agr0