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.
Related
I'm new to geoserver and I'm trying to understand the basics. So expect (I do) that I missed an obvious detail :-/.
I have a problem with the Insert Transaction request in the Demos available in the geoserver web interface. Simply, it does not show anything on the preview (tasmania_roads), as I expect. Instead, the Update demo works ok. The following is how to reproduce.
I have installed geoserver+postgis from kartoza on dockerhub on my linux workstation.
https://hub.docker.com/r/kartoza/geoserver/
and it works ok with:
$ docker pull kartoza/postgis
$ docker pull kartoza/geoserver
$ docker run --name "postgis" -d -t kartoza/postgis
$ docker run --name "geoserver" --link postgis:postgis -p 8080:8080 -d -t kartoza/geoserver`
The geoserver web interface is on 172.17.0.3:8080, and the servers are clean (no admin access on geoserver and postgis).
Now I cut the code of the demo (link Demos on the left of the geoserver web interface and select request "WFS_transactionInsert.xml") and copy it in a file (DemoInsert). I modify the IP of the geoserver and this is the result:
<wfs:Transaction service="WFS" version="1.0.0"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:topp="http://www.openplans.org/topp"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd http://www.openplans.org/topp http://172.17.0.3:8080/geoserver/wfs/DescribeFeatureType?typename=topp:tasmania_roads">
<wfs:Insert>
<topp:tasmania_roads>
<topp:the_geom>
<gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:lineStringMember>
<gml:LineString>
<gml:coordinates decimal="." cs="," ts=" ">
494475.71056415,5433016.8189323 494982.70115662,5435041.95096618
</gml:coordinates>
</gml:LineString>
</gml:lineStringMember>
</gml:MultiLineString>
</topp:the_geom>
<topp:TYPE>alley</topp:TYPE>
</topp:tasmania_roads>
</wfs:Insert>
Finally I POST the query to the geoserver:
curl -X POST -d #DemoInsert -H "Content-Type: text/xml" http://172.17.0.3:8080/geoserver/wfs
and the reply is:
<?xml version="1.0" encoding="UTF-8"?>
<wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://172.17.0.3:8080/geoserver/schemas/wfs/1.0.0/WFS-transaction.xsd">
<wfs:InsertResult>
<ogc:FeatureId fid="new0"/>
</wfs:InsertResult>
<wfs:TransactionResult>
<wfs:Status>
<wfs:SUCCESS/>
</wfs:Status>
</wfs:TransactionResult>
</wfs:WFS_TransactionResponse>
(here I have added some newlines).
But nothing happens on the map that I see in Data, Layer Preview in the geoserver web interface. Note that a similar trick with the Update Transaction demo works perfectly.
Anybody can help me?
Thank you...
You have told GeoServer that the feature you are adding is in EPSG:4326 (that's srsName="http://www.opengis.net/gml/srs/epsg.xml#4326") but your coordinates are
494475.71056415,5433016.8189323 494982.70115662,5435041.95096618
which are clearly not in latitude and longitude degrees. So GeoServer has added them but they are a long way away from Tasmania so you can't see them, unless you zoom out a lot and then they will be too small to see.
So you either need to use the correct projection information for your geometry (I can't be sure but maybe EPSG:3758 Web Mercator?) or provide the coordinates in latitude/longitude format.
You might also want to raise a bug on the GeoServer Jira about this error.
My understanding of the process:
From mediawikis login manual https://www.mediawiki.org/wiki/API:Login
When using MediaWiki's web service API, you will probably need your application or client to log in. This involves submitting a login query, constructing a cookie, and confirming the login by resubmitting the login request with the confirmation token returned.
1) Attempt to login with username and password, this will fail with 'result="NeedToken"' as part of response html. Response will also contain the token to be passed in for the next login attempt.
2) Attempt to login again, this time passing in token in addition to un/pw. This should return with 'result="Success"'
My code:
###Attempt first login setup cookie jar
loginRes1=$(curl --cookie-jar cjar -X POST "$domain/wiki/api.php?action=login&lgname=$lgname&lgpassword=$lgpassword")
###Grab the token from login attempt
lgtoken=$(echo $loginRes1 |sed -rn "s/.*token="([0-9a-zA-Z]+)".*/\1/p" )
###Attempt second login, this time passing token as well
loginRes2=$(curl --cookie-jar cjar -X POST "$domain/wiki/api.php?action=login&lgname=$lgname&lgpassword=$lgpassword&lgtoken=$lgtoken")
Result:
echo $loginRes1
###Only relevant html from echo shown below, cleaned up into xml syntax
<?xml version="1.0"?> <api> <login result="NeedToken" token="944af711913a037cfb8b90d477d51f6c" cookieprefix="ronk" sessionid="isqvhm955lj35g1q2e2klme091" /> </api>
echo $loginRes2
###Only relevant html from echo shown below, cleaned up into xml syntax
<?xml version="1.0"?> <api> <login result="NeedToken" token="ffdd1aa6dc3699df26b9de6dd1c6d5a5" cookieprefix="ronk" sessionid="fdahoh4gh7junrqm1tk2p1qd25" /> </api>
I'm still getting the NeedToken result the second time, instead of Success as I would expect.
Logging in via browser
I can login normally with a browser with a form submission, the post request contains 4 parameters: wpName, wpPassword, wpLoginAttempt, wpLoginToken
wpName=myName&wpPassword=myPassword&wpLoginAttempt=Log+in&wpLoginToken=d3fe3a1de6fbc934acd3039149f3c56d
Other Notes
1) I confirmed that the un/pw works when logging in normally through a browser.
2) It's unclear to me if I'm using the curl cookie-jar syntax appropriately
3) I don't know the version of mediawiki I'm connecting to, it was installed recently and is likely the highest stable version.
4) You'll notice in the successful browser attempt, the parameters have the wp prefix instead of lg, if I change the curl attempt to match (i.e. wpName, wpPassword) then the returned result is:
<?xml version="1.0"?> <api> <warnings> <main xml:space="preserve">Unrecognized parameters: 'wpName', 'wpPassword'</main> </warnings> <login result="NoName" /> </api>
The --cookie-jar option to curl only tells curl to save cookies to the jar. It doesn't tell curl to load cookies from the jar.
To get curl to load cookies from the jar you need to use the -b option to specify the cookie jar to use.
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 :-)
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
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