Java 有关WSDL端口的详细信息
我正在学习,对于Java 有关WSDL端口的详细信息,java,web-services,wsdl,Java,Web Services,Wsdl,我正在学习,对于WSDL端口提到: 一个端口不能指定多个地址 端口不能指定地址以外的任何绑定信息 信息 给出的例子是: <portType name="StockQuotePortType"> <operation name="GetLastTradePrice"> <input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceO
WSDL
端口
提到:
一个端口不能指定多个地址
端口不能指定地址以外的任何绑定信息
信息
给出的例子是:
<portType name="StockQuotePortType">
<operation name="GetLastTradePrice">
<input message="tns:GetLastTradePriceInput"/>
<output message="tns:GetLastTradePriceOutput"/>
</operation>
</portType>
本例中的地址是什么?也就是说,
端口不能指定地址信息以外的任何绑定信息。
?请帮助我理解这些概念。我认为您引用了错误的示例,它是在服务标签下谈论端口。像这样的,
<wsdl:service name="StockQuote">
<wsdl:port name="StockQuoteSoap" binding="tns:StockQuoteSoap">
<soap:address location="http://www.webservicex.net/stockquote.asmx" />
</wsdl:port>
<wsdl:port name="StockQuoteSoap12" binding="tns:StockQuoteSoap12">
<soap12:address location="http://www.webservicex.net/stockquote.asmx" />
</wsdl:port>
<wsdl:port name="StockQuoteHttpGet" binding="tns:StockQuoteHttpGet">
<http:address location="http://www.webservicex.net/stockquote.asmx" />
</wsdl:port>
<wsdl:port name="StockQuoteHttpPost" binding="tns:StockQuoteHttpPost">
<http:address location="http://www.webservicex.net/stockquote.asmx" />
</wsdl:port>
这意味着每次,您都将在特定绑定下在此地址位置上发送请求消息
有4个端口,或者你可以说是1个webservices,即StockQuote,但是你可以根据绑定用4种不同的方式调用它
绑定定义每个端口的消息格式和协议详细信息。比如说
<wsdl:binding name="StockQuoteSoap" type="tns:StockQuoteSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetQuote">
<soap:operation soapAction="http://www.webserviceX.NET/GetQuote" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
让我们举一个例子,您希望在以下位置发布Web服务:
url”http://testhost:9999/ws/helloexample“
在java中的包examplePackage中
您有一个名为sayHello的类或接口,其中定义了一个方法公共字符串helloWorld(字符串名称)
您正在使用发布此类
Endpoint.publish("http://testhost:9899/ws/helloexample", new sayHello());
因此,您生成的wsdl将如下所示进行映射
Interface or class name: PortType
Method name: Operation
Method name: input message (request)
Method name+Response: output message (response)
<portType name="sayHello">
<operation name="helloWorld">
<input message="tns:helloWorld"/>
<output message="tns:helloWorldResponse"/>
</operation>
</portType>
Endpoint.publish("http://testhost:9899/ws/helloexample",new sayHello())
: address location
<wsdl:service name="sayHelloService">
<wsdl:port name="sayHelloPort" binding="tns:sayHelloPortBinding">
<soap:address location="http://testhost:9899/ws/helloexample" />
</wsdl:port>
接口或类名:PortType
方法名称:操作
方法名称:输入消息(请求)
方法名称+响应:输出消息(响应)
Endpoint.publish(“http://testhost:9899/ws/helloexample“,new sayHello())
:地址位置
您可以使用各种可用的webservice注释,如@WebParam、@WebMethod、@WebResult等来更改wsdl中的操作名称、消息部分名称、命名空间等
在生成的wsdl中进一步添加了绑定
<wsdl:binding name="sayHelloPortBinding" type="tns:sayHello">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="helloWorld">
<soap:operation soapAction="" style="rpc"/>
<wsdl:input>
<soap:body use="literal" namespace="http://examplePackage" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="http://examplePackage" />
</wsdl:output>
</wsdl:operation>
SOAPAction可以在@WebMethod注释中设置。样式可以在@SOAPBinding anootation中设置。非常感谢:),我有一些疑问,请您澄清一下。(1) 本例中的地址是一个URL,因此它可以有任何值,如
http://myhost/testing
还是我们需要遵循一些流程?(2) 这里的soapAction也是一个URL,所以我和我对地址的怀疑是一样的。(3) 如果我在Java编程中开发服务,那么我们在Java包中定义了类,那么包结构在WSDL中的位置是什么?在发布端点url的发布者类中,您可以根据需要定义任何地址。SOAP操作可以是url,它可以像“packagename/methodname”或像“getQuote”、“login”等字符串。我将正确编辑你第三个问题的答案。
<wsdl:operation name="GetQuote">
<wsdl:portType name="StockQuoteSoap">
<wsdl:operation name="GetQuote">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</wsdl:documentation>
<wsdl:input message="tns:GetQuoteSoapIn" />
<wsdl:output message="tns:GetQuoteSoapOut" />
</wsdl:operation>
soap:operation soapAction="http://www.webserviceX.NET/GetQuote" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output
(3) If I am developing a service in Java programming then we have classes defined in Java package, so where the package structure go in this WSDL?
Endpoint.publish("http://testhost:9899/ws/helloexample", new sayHello());
Interface or class name: PortType
Method name: Operation
Method name: input message (request)
Method name+Response: output message (response)
<portType name="sayHello">
<operation name="helloWorld">
<input message="tns:helloWorld"/>
<output message="tns:helloWorldResponse"/>
</operation>
</portType>
Endpoint.publish("http://testhost:9899/ws/helloexample",new sayHello())
: address location
<wsdl:service name="sayHelloService">
<wsdl:port name="sayHelloPort" binding="tns:sayHelloPortBinding">
<soap:address location="http://testhost:9899/ws/helloexample" />
</wsdl:port>
<wsdl:binding name="sayHelloPortBinding" type="tns:sayHello">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="helloWorld">
<soap:operation soapAction="" style="rpc"/>
<wsdl:input>
<soap:body use="literal" namespace="http://examplePackage" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="http://examplePackage" />
</wsdl:output>
</wsdl:operation>