我试图修改Savon SOAP调用中的一个命名空间。以下是我的请求示例:
HTTPI GET request to www.intg.pathway.verosapps.com (excon)
SOAP request: https://www.intg.pathway.verosapps.com/VerosPathway.svc
SOAPAction: "urn:IVerosPathway/VerosPathway_Ping", Content-Type: text/xml;charset=UTF-8, Content-Length: 434
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<VerosPathway_Ping>
<request>
<Credentials>
<UserId>*username*</UserId>
<Password>*password*</Password>
</Credentials>
</request>
</VerosPathway_Ping>
</soapenv:Body>
</soapenv:Envelope>
由于这家公司期望客户使用.NET进行SOAP交互,而我们正在使用Ruby,因此我不得不进行大量调整。我非常接近正确的格式,但在信封部分需要执行以下两个操作之一:
- 将“xmlns =“http://tempuri.org/””更改为“xmlns:wsdl =“http://tempuri.org/””
- 或者完全删除“xmlns =“http://tempuri.org/””
这是我的Savon调用:
apiClient = Savon.client(endpoint: "https://www.intg.pathway.verosapps.com/VerosPathway.svc", env_namespace: :soapenv, namespace_identifier: nil, logger: Rails.logger, log_level: :debug, log: true, :pretty_print_xml => true, ssl_version: :TLSv1, wsdl: 'https://www.intg.pathway.verosapps.com/VerosPathway.svc?wsdl')
如果我在Savon调用中添加以下行:
namespaces: {"xmlns:wsdl" => "http://tempuri.org/"}
那么我的请求看起来像这样:
然后我的请求是这样的:
HTTPI GET request to www.intg.pathway.verosapps.com (excon)
SOAP request: https://www.intg.pathway.verosapps.com/VerosPathway.svc
SOAPAction: "urn:IVerosPathway/VerosPathway_Ping", Content-Type: text/xml;charset=UTF-8, Content-Length: 434
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://tempuri.org/">
<soapenv:Body>
<VerosPathway_Ping>
<request>
<Credentials>
<UserId>*username*</UserId>
<Password>*password*</Password>
</Credentials>
</request>
</VerosPathway_Ping>
</soapenv:Body>
</soapenv:Envelope>
在这种情况下,我只需要删除“xmlns =“http://tempuri.org/””这一行即可。
非常感谢您的建议。
谢谢!