WSDL 端口的详细信息 [英] Details on WSDL Ports

查看:45
本文介绍了WSDL 端口的详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习使用在线文档的WSDL,用于WSDLPorts 提到:

I am learning WSDL using online documentation, for WSDL Ports it is mentioned that:

一个端口不能指定多个地址.

A port MUST NOT specify more than one address.

端口不得指定地址以外的任何绑定信息信息.

A port MUST NOT specify any binding information other than address information.

给出的例子是:

<portType name="StockQuotePortType">
  <operation name="GetLastTradePrice">
    <input message="tns:GetLastTradePriceInput"/>
    <output message="tns:GetLastTradePriceOutput"/>
  </operation>
</portType>

这个例子中的地址是什么?还有端口不能指定地址信息以外的任何绑定信息.是什么意思?请帮助我理解这些概念.

What is address in this example? also what it means that A port MUST NOT specify any binding information other than address information.? Please help me in understanding the concepts.

推荐答案

我想你引用了错误的例子,它是在谈论服务标签下的端口.像这样,

I think you have referred wrong example, It was talking about port under service tag. Something like this,

<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>

在这里你可以看到这个特定网络服务的地址位置,即

Here you can see address location of this particular webservice i.e.

http://www.webservicex.net/stockquote.asmx

这意味着每次,您都会在特定绑定下的此地址位置发送请求消息.

That means each time, you will send your request message on this address location under a specific binding.

有 4 个端口,或者您可以说 1 个网络服务,即 StockQuote,但您可以根据绑定以 4 种不同的方式调用它.

There are 4 ports or you can say 1 webservices i.e. StockQuote but you can call it in 4 different ways as per bindings.

Bindings 定义了每个端口的消息格式和协议细节.例如.

Bindings defines message format and protocol details for each port. For example.

<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>

假设您正在使用StockQuoteSoap"端口调用 StockQuote 网络服务.因此,在发送请求时,您将使用端口标记中提到的上述绑定.

Lets say you are calling StockQuote webservice using "StockQuoteSoap" port. So while sending your request you will use above binding as referred in port tag.

<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />

http 传输协议和 soap 消息传递协议.

http transport protocol and soap messaging protocol.

<wsdl:binding name="StockQuoteSoap" type="tns:StockQuoteSoap">

tns:StockQuoteSoap 指的是您的端口类型

tns:StockQuoteSoap is referring at your port type

<wsdl:operation name="GetQuote">

GetQuote 是您的操作名称.

GetQuote is your operation name.

这个比较关心,你的webservice是如何在服务器端为这个绑定实现的.在传统的编程语言中,您可以将操作名称视为方法名称,将端口类型视为类名称.

This is more concerned, how your webservice is implemented on server side for this binding. You can consider operation name as method name and port type as class name in traditional programming language.

完整的端口类型定义可以在wsdl中看到

Full port type difinition can be seen in wsdl as

<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>

这意味着 StockQuoteSoap 类的 GetQuote 方法将在服务器上针对定义中的给定输入和输出消息执行.

That means GetQuote method of StockQuoteSoap class will be executed at server for given input and output message in definition.

  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

您的绑定还指定了输入和输出消息格式和样式

your binding also specifies input and output message format and style

SOAP Action 是可选功能,服务器使用它来过滤传入的请求.

SOAP Action is optional feature which is used by server to filter out incoming request.

(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? 

让我们举个例子,你想在url "http://testhost:9999/ws/helloexample" in java in package examplePackage.

Lets take an example where, you want to publish a webservice at url "http://testhost:9999/ws/helloexample" in java in package examplePackage.

您有一个名为 sayHello 的类或接口,您在其中定义了一个方法 public String helloWorld (String Name).

You have a class or interface named sayHello in which you have defined a method public String helloWorld (String Name).

您正在使用

Endpoint.publish("http://testhost:9899/ws/helloexample", new sayHello());

所以你生成的 wsdl 将被映射如下.

So your generated wsdl will be mapped like below.

  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>

你可以使用@WebParam、@WebMethod、@WebResult 等各种可用的 webservice 注释来更改 wsdl 中的操作名称、消息部分名称、命名空间等.

You can use various webservice annotations available like @WebParam, @WebMethod, @WebResult etc to change operation name, message part name, namespace etc in wsdl.

在生成的 wsdl 中进一步添加绑定,

Further addidng binding in generated 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 中设置.

SOAPAction can be set in @WebMethod annotation. style can be set in @SOAPBinding anootation.

这篇关于WSDL 端口的详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆