当前位置: 首页 > 知识库问答 >
问题:

WSDL港口详情

微生令雪
2023-03-14

我正在使用在线文档学习 WSDL,对于 WSDL 端口,提到:

端口不得指定多个地址。

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

并且给出的示例是:

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

这个例子中的地址是什么?这也意味着< code >端口不能指定除地址信息之外的任何绑定信息。?请帮助我理解这些概念。

共有1个答案

东方和煦
2023-03-14

我认为你提到了错误的例子,它在谈论服务标签下的端口。像这样的东西,

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

在这里,您可以看到此特定Web服务的地址位置,即。

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

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

有 4 个端口,或者您可以说 1 个网络服务,即 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>

假设您正在使用“斯托克报价肥皂”端口调用斯托克报价网络服务。因此,在发送请求时,您将使用端口标签中提到的上述绑定。

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

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

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

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

<wsdl:operation name="GetQuote">

GetQuote是您的操作名称。

这更重要的是,您的Web服务如何在服务器端实现此绑定。在传统编程语言中,可以将操作名视为方法名,将端口类型视为类名。

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

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

这意味着对于定义中给定的输入和输出消息,斯托克·奎特·索普类的GetQuoteSoap方法将在服务器上执行。

  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

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

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

(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“在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>

您可以使用各种可用的Web服务注释,例如@WebParam、@Web方法、@WebResault等来更改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>

可以在@WebMethod注释中设置 SOAPAction。样式可以在@SOAPBinding设置。

 类似资料:
  • 我通过执行以下命令,在我的两个Apache Karaf 2.2.7实例中安装了hawtio: 问题是我有四个linux机器和四个Karaf实例,所以我在每个机器上都安装了它。除了hawtio控制台端口不同之外,一切都很好。我知道默认情况下它应该在< code>8181上启动。在我的两个服务器上,它开始于:< code>8182,在另外两个服务器上:< code>7181。我不确定,也许< code

  • 我有一个JAX-WS导入的WSDL客户机。当我尝试连接到webserviceendpoint时,JAX-WS客户端尝试加载WSDL。为什么? 我不想在我的项目中存储WSDL, 我不想再次从webservice URL加载WSDL? 问题: 有机会绕过这种行为吗? 如何在运行时添加webserviceendpointURL? 添加具有相同QName和端口名的端口失败,因为我无法添加相同的QName和

  • 我的expo go应用程序出错。 错误: 未捕获的错误:java.net.SocketTimeout异常:10000ms后无法从/192.168.100.2(端口39440)连接到/192.168.100.10(端口19000)。

  • 我制作了一个customer-pod(包括一个运行在端口8080上的Spring Boot应用程序的映像)。 我可以用“$kubectl get pods commands-o wide”来检查它 ================================================================= 名称就绪状态重新启动老化IP节点

  • 我创建了一个有2个节点的kubernetes集群(GCP GKE)。我为druid(端口2181)设置了zookeeper我工作得很好,但是,我想在同一个集群中部署kafka pod。所以我使用helm,但是当我在脚本values.yaml末尾更改端口时,我运行helm upgrade如下所示 并使用