How would I remove the HTTP headers from a Savon request for example
client.request 'v5:ProcessShipments' do
client.http.headers["SOAPAction"] = "example_post"
end
This would generate
DEBUG -- : SOAPAction: example_post
And the server would respond
Server did not recognize the value of HTTP Header SOAPAction: example_post.
However I dont want to have any SOAPAction(s)
I have tried to clear the variable and delete it. I search for a while and couldn't find anything so I hope this hasn't been asked before.
Thanks in advance.
If I dont override it then by default Savon will use the client.request 'v5:ProcessShipments', which is also incorrect.
Here is a quote from savon documentation for the future references:
SOAPAction is an HTTP header information required by legacy services.
If present, the header value must have double quotes surrounding the
URI-reference (SOAP 1.1. spec, section 6.1.1).
By reading savon source code I figured out that Savon::Client#request method sets "SOAPAction" header automatically before it yields a block. I tried to delete SOAPAction header and it worked:
require 'savon'
client = Savon::Client.new do
wsdl.document = "test.wsdl"
end
client.request :wsdl, "sayHello" do
http.headers.delete("SOAPAction")
end
Here is the request it generates:
SOAP request: http://www.examples.com/SayHello/
DEBUG -- : Content-Type: text/xml;charset=UTF-8, Content-Length: 332
DEBUG -- :
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<wsdl:sayHello></wsdl:sayHello>
</env:Body>
</env:Envelope>
As you can see there is no SOAPAction HTTP header.
HTH
Related
could someone provide me with a MWE for a FHIR PATCH operation in XML format on the public test.fhir.org test server. This is what I got:
Request:
PATCH http://test.fhir.org/r4/Patient/12345
Content-Type: application/xml-patch+xml
<replace sel="/name/family/#value">Schmidt</replace>
Error:
Error parsing resource Xml (This does not appear to be a FHIR element or resource (wrong namespace "") # /)
I similiar JSON operation woks fine:
PATCH http://test.fhir.org/r4/Patient/12345
Content-Type: application/json-patch+json
[{
"op": "replace",
"path": "/name/0/family",
"value": "Meyer"
}]
I've searched a lot and couldn't find an MWE for an XML Patch operation, only JSON.
Best
Tobias
You are missing the XML namespace. If you add this line to create a valid XML document, it should work:
<?xml version="1.0" encoding="UTF-8"?>
Guys I have got an issue with wsdl processing.
Cerberus FTP server has it's own wsdl API for server configuration
www.cerberusftp.com/support/help/webservices.htm
I tried to execute some functions with ruby and savon like this:
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
require 'savon'
client = Savon.client(wsdl: "http://192.168.1.5:10001/wsdl/Cerberus.wsdl")
response = client.call(:server_information) do
message credentials: {user: "admin", password: "123"}
end
From sniffer I can see POST request
<?xml version="1.0" encoding="UTF-8" ?>
- <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://cerberusllc.com/service/cerberusftpservice" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
- <env:Body>
- <tns:ServerInformationRequest>
- <tns:credentials>
<tns:user>admin</tns:user>
<tns:password>123</tns:password>
</tns:credentials>
</tns:ServerInformationRequest>
</env:Body>
</env:Envelope>
Also I tried tool Membarene SOAP client
<s12:Envelope xmlns:s12='http://www.w3.org/2003/05/soap-envelope'>
<s12:Body>
<ns1:ServerInformationRequest xmlns:ns1='http://cerberusllc.com/service/cerberusftpservice'>
<ns1:credentials xmlns:ns1='http://cerberusllc.com/common'>
<ns1:user>admin</ns1:user>
<ns1:password>123</ns1:password>
</ns1:credentials>
</ns1:ServerInformationRequest>
</s12:Body>
</s12:Envelope>
It's POST request slightly different and it works.
Any idea how to do the same in ruby + savon ?
I've resolved that issue.
I generate XML query manually.
it looks like:
client = Savon.client(wsdl: "http://example.com:10001/wsdl/Cerberus.wsdl")
variable = client.call(:add_group xml: "your xml " ) # you can generate this xml via SoapUI tool or Membarene SOAP client.
My standard response:
download SoapUI
build a valid, successful call
rebuild in Ruby with Savon (not RoR)
ask questions here and you will receive help :-)
I am trying to make POST request with Net::HTTP to specific website, and start downloading file after response is returned.
I tested this first with wget, and it worked fine.I also tried with httpi and unirest gems and it went fine . However, because Net::HTTP is low-level API and I need more control(for example, tracking downloading progress), I'll stick with it.
The problem is, downloading just won't start.So here's the code:
require 'net/http'
require 'tempfile'
uri = URI.parse("http://mywebsite.com")
req = Net::HTTP::Post.new(uri.path)
req.set_form_data({'filed' => 'data'})
response = Net::HTTP.start(uri.hostname, uri.port) {|http|
http.request(req) do |response|
temp_file = Tempfile.new("new_file")
response.read_body do |chunk|
temp_file << chunk
end
end
}
I figured that the problem must be in response, what I get is not Net::HTTPOK
but HTTPSeeOther and here's more info about it
#<Net::HTTPSeeOther:0x91f2670>
{"server"=>["nginx"], "date"=>["Sat, 21 Dec 2013 22:32:14 GMT"],
"content-type"=>["text/html"], "transfer-encoding"=>["chunked"],
"connection"=>["keep-alive"], "pragma"=>["no-cache"],
"cache-control"=>["no-cache, must-revalidate"],
"expires"=>["Sat, 26 Jul 1997 05:00:00 GMT"],
"location"=>["http://mywebsite.com/path/to/file.rar"]}
The other 2 gems I mentioned knew how to start download automatically and I don't know what to do with HTTPSeeOther .
It appears that you're getting a redirect response from the server, which wget, curl, and high-level libraries will follow automatically. With Net::HTTP, you'll need to start a new GET request to that location.
The below works perfectly in SoapUI (that's where I constructed it), but when I copy the exact request and attempt to execute with cURL in the bash command line (cygwin actually), it says:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode>
<faultstring>no SOAPAction header!</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
The command I'm using is:
curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:" -d "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ebay:apis:eBLBaseComponents"><soapenv:Header><urn:RequesterCredentials><urn:eBayAuthToken>AgA***GO</urn:eBayAuthToken></urn:RequesterCredentials></soapenv:Header><soapenv:Body><urn:GetMyeBaySellingRequest><urn:Version>793</urn:Version><urn:ActiveList><urn:Include>1</urn:Include><urn:IncludeNotes>0</urn:IncludeNotes></urn:ActiveList><urn:OutputSelector>ActiveList.ItemArray.Item.ItemID</urn:OutputSelector><urn:DetailLevel>ReturnAll</urn:DetailLevel><urn:HideVariations>1</urn:HideVariations></urn:GetMyeBaySellingRequest></soapenv:Body></soapenv:Envelope>" -X POST https://api.ebay.com/wsapi?callname=GetMyeBaySelling
I've used this exact syntax on other APIs with no issue, not sure what's different about eBay.
Open your wsdl. search for the operation which you are using to send this "GetMyeBaySellingRequest" request.
Copy the soap action from there and add in you command line
"SOAPAction: add soap action here from bindings or from soapui"
or in SOAP UI click on the operation and see at bottom left corner, you will see "operation properties". From there copy soap action value and put it in your command.
I'm trying to transfer a value from the response of one WS call to the request of another using SoapUI's Transfer Property TestStep.
First WS response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<ns5:PSResponse xmlns:ns5="http://www.ab.com/abonline/service/PaymentService/1.0/" xmlns:ns6="http://www.ab.com/abonline/service/CustomerCard/1.0/" xmlns:ns7="https://secure.incab.se/DTServerModuleService/v1">
<ns5:abTransactionReference>1085-0</ns5:abTransactionReference>
<ns5:status>0</ns5:status>
</ns5:PSResponse>
</soapenv:Body>
</soapenv:Envelope>
Parsing the property works fine using an expression like:
declare namespace ns5="http://www.ab.com/abnline/service/PaymentService/1.0/"
//ns5:abTransactionReference
The next request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.ab.com/abonline/service/PaymentService/1.0/">
<soapenv:Header/>
<soapenv:Body>
<UpdatePaymentRequest>
<abTransactionReference>30</abTransactionReference>
... ...
I try inserting the property into the next request using:
//abTransactionReference
Gives me: [Missing match for Target XPath [//abTransactionReference]]
I also tried a full xpath:
declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/"
//soapenv:Envelope/soapenv:Body/UpdatePaymentRequest/abTransactionReference
...resulting in similar error.
it seems you should set the default namespace to http://www.ab.com/... as well
You cannot use "" for the namespace definition. For example, in the case above >>
declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/"
should be
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
Try to add XPath Assertions to UpdatePaymentRequest request message. Click on the Declare button on the XPath Match Configuration dialog and you will see what prefix soapUI uses for 'http://www.ab.com/abonline/service/PaymentService/1.0/' namespace. I think it will be like:
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://www.ab.com/abonline/service/PaymentService/1.0/';
(see http://testautomationnoob.blogspot.com.by/2013/12/xpath-in-soapui-part-1-xpath-assertions.html). Then there is no need to have XPath Assertions - you can remove it. So, use "ns1" prefix in your xpath. In the end you will have the following xpath:
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://www.ab.com/abonline/service/PaymentService/1.0/';
/soapenv:Envelope/soapenv:Body/ns1:UpdatePaymentRequest/ns1:abTransactionReference