SOAP 操作 WSDL

发布于 2024-08-21 06:42:26 字数 1725 浏览 5 评论 0原文

我正在尝试为 National Rail Enquiries 的 SOAP 服务实现一个客户端 (http://www.livedepartureboards. co.uk/ldbws/)。

我坚持使用 WSDL (http://realtime.nationalrail.co.uk/ldbws/wsdl。 aspx)进入 http://soapclient.com/soaptest.html,但我回来了错误消息“无法处理没有有效操作参数的请求。请提供有效的肥皂操作。”;到底应该采取什么行动呢?

谢谢, 斯图尔特

编辑:

我只是用soapclient.com 作为一个简单的例子。在我的软件中,我发送以下 XML;我仍然知道我错过了一个动作。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://thalesgroup.com/RTTI/2008-02-20/ldb/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ldbt2="http://thalesgroup.com/RTTI/2008-02-20/ldb/types" xmlns:ldbt="http://thalesgroup.com/RTTI/2007-10-10/ldb/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ct="http://thalesgroup.com/RTTI/2007-10-10/ldb/commontypes" >
 <SOAP-ENV:Body>
  <ldbt2:GetDepartureBoardRequest xmlns:ldbt2="http://thalesgroup.com/RTTI/2008-02-20/ldb/" >
   <ldbt2:numRows>5</ldbt2:numRows>
   <ldbt2:crs>WAT</ldbt2:crs>
   <ldbt2:filterCrs>GLD</ldbt2:filterCrs>
   <ldbt2:filterType>to</ldbt2:filterType>
   <ldbt2:timeOffset>0</ldbt2:timeOffset>
  </ldbt2:GetDepartureBoardRequest>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I'm trying to implement a client for National Rail Enquiries' SOAP Service (http://www.livedepartureboards.co.uk/ldbws/).

I stick the WSDL (http://realtime.nationalrail.co.uk/ldbws/wsdl.aspx) into http://soapclient.com/soaptest.html, but I get back the error message "Unable to handle request without a valid action parameter. Please supply a valid soap action."; what on earth should the action be?

Thanks,
Stewart

edit:

I just used soapclient.com as a quick example. In my software, I send the following XML; I still get that I'm missing an action.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://thalesgroup.com/RTTI/2008-02-20/ldb/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ldbt2="http://thalesgroup.com/RTTI/2008-02-20/ldb/types" xmlns:ldbt="http://thalesgroup.com/RTTI/2007-10-10/ldb/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ct="http://thalesgroup.com/RTTI/2007-10-10/ldb/commontypes" >
 <SOAP-ENV:Body>
  <ldbt2:GetDepartureBoardRequest xmlns:ldbt2="http://thalesgroup.com/RTTI/2008-02-20/ldb/" >
   <ldbt2:numRows>5</ldbt2:numRows>
   <ldbt2:crs>WAT</ldbt2:crs>
   <ldbt2:filterCrs>GLD</ldbt2:filterCrs>
   <ldbt2:filterType>to</ldbt2:filterType>
   <ldbt2:timeOffset>0</ldbt2:timeOffset>
  </ldbt2:GetDepartureBoardRequest>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

最近可好 2024-08-28 06:42:26

如果它是 SOAP 1.1 服务,那么您还需要包含 SOAPAction HTTP 标头字段:

http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528

If its a SOAP 1.1 service then you will also need to include a SOAPAction HTTP header field:

http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528

飘逸的'云 2024-08-28 06:42:26

当我尝试使用 Perl 为国家铁路 SOAP 服务编写客户端时,我遇到了完全相同的问题。

引起该问题的原因是我使用“SOAP::Lite”的 Perl 模块在 SOAPAction 标头中插入了“#”....

SOAPAction: "http://thalesgroup.com/RTTI/2008-02-20/ldb/#GetDepartureBoard"

NET 服务器无法正确解释这一点。我从 O'Reilly 的示例 3-19 中发现了这一点使用 SOAP 进行 Web 服务编程< /a> 。下面第3-20节给出了解决方案,即您需要使用'on_action'方法显式指定标头的格式。

print SOAP::Lite
  -> uri('urn:Example1')
  -> on_action(sub{sprintf '%s/%s', @_ })
  -> proxy('http://localhost:8080/helloworld/example1.asmx')
  -> sayHello($name)
  -> result . "\n\n";

我的猜测是,soapclient.com 在幕后使用 SOAP::Lite,因此在与国家铁路公司交谈时遇到了同样的问题。

解决方案是编写您自己的客户端,以便您可以控制 SOAPAction 标头的格式……但您可能已经这样做了。

I have come across exactly the same problem when trying to write a client for the National Rail SOAP service with Perl.

The problem was caused because the Perl module that I'm using 'SOAP::Lite' inserts a '#' in the SOAPAction header ...

SOAPAction: "http://thalesgroup.com/RTTI/2008-02-20/ldb/#GetDepartureBoard"

This is not interpreted correctly by .NET servers. I found this out from Example 3-19 in O'Reilly's Programming Web Services with SOAP . The solution was given below in section 3-20, namely you need to explicitly specify the format of the header with the 'on_action' method.

print SOAP::Lite
  -> uri('urn:Example1')
  -> on_action(sub{sprintf '%s/%s', @_ })
  -> proxy('http://localhost:8080/helloworld/example1.asmx')
  -> sayHello($name)
  -> result . "\n\n";

My guess is that soapclient.com is using SOAP::Lite behind the scenes and so are hitting the same problem when talking to National Rail.

The solution is to write your own client so that you have control over the format of the SOAPAction header ... but you've probably done that already.

旧梦荧光笔 2024-08-28 06:42:26

当 SOAP 1.2 请求中缺少 soapAction 时(许多客户端没有设置它,即使在 WSDL 中指定了它),某些应用程序服务器(例如 jboss)会推断出“实际”来自{xsd:导入命名空间}+{wsdl:操作名称}的soapAction
因此,为了使推断的“实际”soapAction 与预期的soapAction 匹配,您可以将预期的soapAction 设置为{xsd:import namespace}+{wsdl:operation name} 在您的 WS 定义中(对于 Java EE,@WebMethod(action=...)

)对于典型的 Java EE 案例,这会有所帮助(不是斯图尔特的案例,国家铁路 WS 设置了“soapAction”):

@WebMethod(action = "http://packagename.of.your.webservice.class.com/ methodName")

如果您无法更改服务器,则必须强制客户端填充 soapAction

When soapAction is missing in the SOAP 1.2 request (and many clients do not set it, even when it is specified in WSDL), some app servers (eg. jboss) infer the "actual" soapAction from {xsd:import namespace}+{wsdl:operation name}.
So, to make the inferred "actual" soapAction match the expected soapAction, you can set the expected soapAction to {xsd:import namespace}+{wsdl:operation name} in your WS definition (@WebMethod(action=...) for Java EE)

Eg. for a typical Java EE case, this helps (not the Stewart's case, National Rail WS has 'soapAction' set):

@WebMethod(action = "http://packagename.of.your.webservice.class.com/methodName")

If you cannot change the server, you will have to force client to fill soapAction.

稀香 2024-08-28 06:42:26

SOAPAction 在 SOAP 1.1 中是必需的,但可以为空 ("")。

请参阅https://www.w3.org/TR/2000/NOTE -SOAP-20000508/#_Toc478383528

“标头字段值为空字符串 ("") 表示 SOAP 消息的意图由 HTTP Request-URI 提供。"

尝试设置 SOAPAction=""

SOAPAction is required in SOAP 1.1 but can be empty ("").

See https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528

"The header field value of empty string ("") means that the intent of the SOAP message is provided by the HTTP Request-URI."

Try setting SOAPAction=""

芯好空 2024-08-28 06:42:26

我刚刚花了一段时间试图让它工作并编写了一个 Ruby gem 来访问API。您可以在项目页面上了解更多信息。

这是 Ruby 中的工作代码:

require 'savon'
client = Savon::Client.new do
  wsdl.document = "http://realtime.nationalrail.co.uk/LDBWS/wsdl.aspx"
end

response = client.request 'http://thalesgroup.com/RTTI/2012-01-13/ldb/GetDepartureBoard' do

  namespaces = {
    "xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/",
    "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
    "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema"
  }

  soap.xml do |xml|
    xml.soap(:Envelope, namespaces) do |xml|
      xml.soap(:Header) do |xml|
        xml.AccessToken do |xml|
          xml.TokenValue('ENTER YOUR TOKEN HERE') 
        end
      end
      xml.soap(:Body) do |xml|
        xml.GetDepartureBoardRequest(xmlns: "http://thalesgroup.com/RTTI/2012-01-13/ldb/types") do |xml|
          xml.numRows(10)
          xml.crs("BHM")
          xml.filterCrs("BHM")
          xml.filterType("to")
        end
      end
    end
  end
end
p response.body

希望对某人有帮助!

I've just spent a while trying to get this to work an have a written a Ruby gem that accesses the API. You can read more on it's project page.

This is working code in Ruby:

require 'savon'
client = Savon::Client.new do
  wsdl.document = "http://realtime.nationalrail.co.uk/LDBWS/wsdl.aspx"
end

response = client.request 'http://thalesgroup.com/RTTI/2012-01-13/ldb/GetDepartureBoard' do

  namespaces = {
    "xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/",
    "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
    "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema"
  }

  soap.xml do |xml|
    xml.soap(:Envelope, namespaces) do |xml|
      xml.soap(:Header) do |xml|
        xml.AccessToken do |xml|
          xml.TokenValue('ENTER YOUR TOKEN HERE') 
        end
      end
      xml.soap(:Body) do |xml|
        xml.GetDepartureBoardRequest(xmlns: "http://thalesgroup.com/RTTI/2012-01-13/ldb/types") do |xml|
          xml.numRows(10)
          xml.crs("BHM")
          xml.filterCrs("BHM")
          xml.filterType("to")
        end
      end
    end
  end
end
p response.body

Hope that's helpful for someone!

小苏打饼 2024-08-28 06:42:26

我们在 Windows Server 上整合了 Web 服务,并尝试与 Apache 上的 PHP 连接。我们遇到了同样的错误。问题最终是不同服务器上的 Soap 客户端版本不同。匹配两台服务器上选项中的 SOAP 版本解决了我们案例中的问题。

We put together Web Services on Windows Server and were trying to connect with PHP on Apache. We got the same error. The issue ended up being different versions of the Soap client on the different servers. Matching the SOAP versions in the options on both servers solved the issue in our case.

滿滿的愛 2024-08-28 06:42:26

该服务有 4 个操作:
1. 获取服务详细信息
2. 获取到达板
3. 获取出发板
4. GetArrivalDepartureBoard

Web 服务的实现

the service have 4 operations:
1. GetServiceDetails
2. GetArrivalBoard
3. GetDepartureBoard
4. GetArrivalDepartureBoard

Implementation of web service

Smile简单爱 2024-08-28 06:42:26

我已经解决了这个问题,在Java代码中添加:

 MimeHeaders headers = message.getMimeHeaders();
 headers.addHeader("SOAPAction", endpointURL);

I have solved this problem, in Java Code, adding:

 MimeHeaders headers = message.getMimeHeaders();
 headers.addHeader("SOAPAction", endpointURL);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文