Here It's my request xml :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Request>
<user>
<title>Mr</title>
<firstname>automation</firstname>
<lastname>Qa</lastname>
<department>Automation</department>
<mobile>999000777</mobile>
</user>
</Request>
Here it's my actual Rest Assured Code :
String APIUrl = "http://autoTest.com/api/1/user/create";
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("title", "Mr");
hashMap.put("firstname", "automation");
hashMap.put("lastname", "testing");
hashMap.put("department", "test");
hashMap.put("mobile", "7878787");
Response response = RestAssured.given().auth().preemptive() .basic("userName", "passw0rd").
parameters(hashMap).when().post(APIUrl);
When i do this call it's give me Following kind of Error in console :
Bad request ,
Request resource or xml is not valid ,
Sorry, we could not find appropriate method or xml.
Can anyone help me to find what i am doing wrong?
You might need to add contentType("application/xml") so that rest assured knows that it should serialize the map as XML.
Related
In Qmetry, trying to validate xpath from the soap api response. But it returns false.
API response has root is <soapenv:Envelope (can't paste full response as its content is big)
When tried running below steps. With both options below.
And response should have xpath '/soapenv:Envelope'
And response should have xpath '/Envelope'
This returns False though the response has xpath.
Can any one please help me in resolving this isse?
If Envelope is root element you should not use it in argument to response should have xpath. Given following as sample response:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">
<SOAP-ENV:Body xmlns:m = "http://www.example.com/quotation">
<m:GetQuotationResponse>
<m:Quotation>Here is the quotation</m:Quotation>
</m:GetQuotationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The root node (Envelope in this case)need not to be added in xpath or used as .
Following xpaths should work:
./Body
.//Body
//Body
//GetQuotationResponse
//Body/GetQuotationResponse/Quotation
//GetQuotationResponse/Quotation
//Quotation
I got an XML Response
<?xml version="1.0"?>
<List>
<type>MAILBOX</type>
<DOCS>
<DocId>39fece005f28qrn8000003r5</DocId>
<DocNo>123</DocNo>
</DOCS>
<DOCS>
<DocId>39fece005f28qrn8000003r6</DocId>
<DocNo>456</DocNo>
</DOCS>
</List>
I need to parse it so that I can use it and access DocId; what should be proper code to access docid?
You need to set up parsing on the HTTPRequest node, on the Response Message Parsing tab you select XMLNSC as the message domain, then on the output terminal you can use another Compute node and access the parts of the message as normal in ESQL, e.g.: InputBody.List.DOCS[1].DocId
i am using third party Exigo Api request for my app. the service says to send 2 more requests array in the body of main Soap service. Though i tried sending the 2 request in string form in the Body of the main request but i received Empty String . Help me out how should i do this . i got no solution in the manual or on any other site after googling this issue for a week i am posting this question
Exigo Api (Process Transaction Service)
POST /3.0/ExigoApi.asmx HTTP/1.1
Host: api.exigo.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://api.exigo.com/ProcessTransaction"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ApiAuthentication xmlns="http://api.exigo.com/">
<LoginName>string</LoginName>
<Password>string</Password>
<Company>string</Company>
</ApiAuthentication>
</soap:Header>
<soap:Body>
<TransactionalRequest xmlns="http://api.exigo.com/">
<TransactionRequests>
<ApiRequest />
</TransactionRequests>
</TransactionalRequest>
</soap:Body>
</soap:Envelope>
This is the Soap request i have to process and Send Api Request Array in the body of the main request using iOS.
Thanks in Advance
Please check below link, like
let body = envelope.addChild(name: "soap:Body")
let header = body.addChild(name: "soap:Header" , attributes: ["xmlns:m" : "http://www.w3schools.com/transaction/"])
https://github.com/tadija/AEXML
We have tackle same type of issue for our mobile app. We have have implemented adapter that accepts JSON request from Mobile and then translate that into API request which is inculded in MVC Application as wsdl. Can't find any other way to do that.
Objective
Build Soap call via savon v2
What I tried :
my soap call RQ , this is what given in the documentation
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.opentravel.org/OTA/2003/05">
<soapenv:Header/>
<soapenv:Body>
<OTA_AirLowFareSearchRQ TimeStamp="2012-04-18T07:30:42.663Z" Target="Production" Version="1.0" PrimaryLangID="en" AltLangID="en" RetransmissionIndicator="false" xmlns="http://www.opentravel.org/OTA/2003/05">
<POS>
<Source ISOCountry="ZA" ISOCurrency="ZAR" DisplayCurrency="ZAR" DisplayRate="1.0" FirstDepartPoint="CPT" FinalDestinationPoint="JNB">
<RequestorID Type="Company" ID="website" ID_Context="ts" TSAffiliateID="<AFFILIATE_ID>" MessagePassword="<AFFILIATE_PASSWORD>">
<CompanyName><AFFILIATE_ID></CompanyName>
</RequestorID>
</Source>
</POS>
<OriginDestinationInformation RefNumber="0">
<DepartureDateTime>2012-07-26T00:00:00CAT</DepartureDateTime>
<OriginLocation LocationCode="CPT" CodeContext="iata"/>
<DestinationLocation LocationCode="JNB" CodeContext="iata"/>
</OriginDestinationInformation>
<OriginDestinationInformation RefNumber="1">
<DepartureDateTime>2012-07-29T00:00:00CAT</DepartureDateTime>
<OriginLocation LocationCode="JNB" CodeContext="iata"/>
<DestinationLocation LocationCode="CPT" CodeContext="iata"/>
</OriginDestinationInformation>
<TravelPreferences>
<FlightTypePref FlightType="Nonstop" DirectAndNonStopOnlyInd="true"/> <!-- This line is optional – include to filter direct flights only -->
<CabinPref Cabin="Economy"/>
</TravelPreferences>
<TravelerInfoSummary>
<AirTravelerAvail>
<PassengerTypeQuantity Code="7" Quantity="0"/>
<PassengerTypeQuantity Code="8" Quantity="0"/>
<PassengerTypeQuantity Code="9" Quantity="0"/>
<PassengerTypeQuantity Code="10" Quantity="1"/>
</AirTravelerAvail>
</TravelerInfoSummary>
</OTA_AirLowFareSearchRQ>
</soapenv:Body>
</soapenv:Envelope>
my Target Url : eg: http://www.example.com?wsdl
operation name : search
#client = Savon.client(wsdl: ' http://www.example.com?wsdl')
#client.call(:search, message: { 'RefNumber' => '1','DepartureDateTime'=>'2014-09-26T00:00:00CAT','ArrivalDateTime'=>'2012-10-26T00:00:00CAT','OriginLocation'=>'CPT','DestinationLocation'=>'JNB' })
what i am getting :
(SOAP:Server) No handlers could be found for unmarshalling the SOAP body payload
The Soap call i built is correct or i have to build the entire xml of Soap body ?
Any help is appreciated !!
My standard answer:
download SoapUI
build a valid SOAP request.
make sure it works
then replicate the request with Ruby/Savon
if it still doesn't work, ask again
I seem to be getting this error message:
(a:ActionNotSupported) The message with Action 'GetServices' cannot be
processed at the receiver, due to a ContractFilter mismatch at the
EndpointDispatcher. This may be because of either a contract mismatch
(mismatched Actions between sender and receiver) or a binding/security
mismatch between the sender and the receiver. Check that sender and
receiver have the same contract and the same binding (including
security requirements, e.g. Message, Transport, None).
I assume it is something to do with the security/binding setup.
My connection uses HTTP, with basichttpbinding. I've done a lot of searching for the answer, as I always do, but am unable to fix it, and no one here has expertise on Ruby on Rails.
Help would be appreciated.
Below is my code, in Ruby on Rails, which initialises the service and then calls it. Note: I can connect to it fine. It has successfully reported the available methods. Just calling the methods seems to be the problem. I have successfully connected to online test services using the same code. And I use Savon.
def test
puts "web_service: IN"
client = Savon::Client.new do
wsdl.document = "http://hidden.co.uk/myService.svc?wsdl"
end
#response = client.request "GetServices", :xmlns => "http://tempuri.org/" do
soap.header = {}
soap.body = {
"CostCentreNo" => 1,
"filter" => 0
}
end
puts '##########################'
puts #response.to_hash;
end
Below is what my Ruby on Rails sends:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:wsdl="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<GetServices xmlns="http://tempuri.org/">
<CostCentreNo>1</CostCentreNo>
<filter>0</filter>
</GetServices>
</env:Body>
</env:Envelope>
This is what WCF test client sends, (which works)
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IIBCSServices/GetServices</Action>
</s:Header>
<s:Body>
<GetServices xmlns="http://tempuri.org/">
<CostCentreNo>0</CostCentreNo>
<filter>0</filter>
</GetServices>
</s:Body>
</s:Envelope>
It seems to be the way it was being called... Something so simple.
The override Stated on the SAVON Tutorial, recommended if you have an uppercase starting camelcase doesnt work. Maybe the tutorial is outdated. (Note, :wsdl IS required in my case)
So this was not working:
response = client.request :wsdl, "GetCustomerCentreDetails"
Changing it to:
response = client.request :wsdl, :get_customer_centre_details
Then obviously I need a body added to it, and header etc.
The assumption that caused me confusion : Being able to get the WSDL does not mean you are connected to the webservice.
it seems you're missing this part
<Action s:mustUnderstand="1" ...>
you should insert something like the following into your request
soap.header = {"Action" =>
{'env:mustUnderstand' =>
'http://tempuri.org/IIBCSServices/GetServices',
attributes! => { 'mustUnderstand' => "1", 'xmlns' => "..." }
}