I have a soap request returning a response like below:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:authkeyResponse xmlns:ns1="urn:authkey">
<return xsi:type="xsd:string">ALREADY REGISTERED</return>
</ns1:authkeyResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I am invoking the soap using vb script by following the example from http://kapie.com/2007/consuming-soap-web-services-from-vbscript. I get this whole xml in the strSoapReq object but not sure how to parse it so that I can popup only the result which is "ALREADY REGISTERED".
From the example from the link you gave, make sure you call GetResult explicitly.
If you followed the example and based on your SOAP result, it should be:
GetResult(strResult, "result")
Related
I have created an API using the WSO2 Dataservice which return a JSON Object, My client Application waiting for a SOAP response not a JSON response, so I tried to use datamapper to change the response format from JSON to SOAP but it return only and XML format without the SOAP Body and the SOAP envelope. How to hundle this problem?
This is the SOAP response format I would like to get:
<soap:Envelope 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:Body>
<GetFacturesClientResponse xmlns="http://tempuri.org/">
<GetFacturesClientResult>
<code>0</code>
<codeClient>P-2008-043681</codeClient>
<nom>na</nom>
<prenom>ouss</prenom>
</GetFacturesClientResult>
</GetFacturesClientResponse>
</soap:Body>
</soap:Envelope>
But I got this response:
<GetFacturesClientResponse xmlns="http://tempuri.org/">
<GetFacturesClientResult>
<code>0</code>
<codeClient>P-2008-043681</codeClient>
<nom>na</nom>
<prenom>ouss</prenom>
</GetFacturesClientResult>
</GetFacturesClientResponse>
And this is my code:
<datamapper config="gov:datamapper/oussama.dmc" inputSchema="gov:datamapper/oussama_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/oussama_outputSchema.json" outputType="JSON" xsltStyleSheet="gov:datamapper/oussama_xsltStyleSheet.xml"/>
Before the Respond Mediator set the following property.
<property name="messageType" value="application/soap+xml" scope="axis2"/>
Also in your Datamapper section the outputType="XML" not JSON.
Update
As ophychius mentioned. The above content type will create a SOAP 1.2 message and if you need a SOAP 1.1 message set the content type to text/xml. Typically, clients supports both versions.
I'm using Currency Converter webservice to practice groovy script in SoapUI Pro.
In that, I have created a property that should get response / output of the Currency Converter service through groovy script.
For that, I tried the following script which gets all the raw response data :(
I need to get the exact result i.e. converted value and assign to the property.
Can anyone provide me the correct groovy script?
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
<soapenv:Header/>
<soapenv:Body>
<web:ConversionRate>
<web:FromCurrency>USD</web:FromCurrency>
<web:ToCurrency>INR</web:ToCurrency>
</web:ConversionRate>
</soapenv:Body>
</soapenv:Envelope>
Response:
<soap:Envelope 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:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>60.54</ConversionRateResult>
</ConversionRateResponse>
</soap:Body>
</soap:Envelope>
Thanks
Karunagara Pandi
First you need access to the Response.
def conversionRateResult = context.expand( '${step_name#Response#//*:ConversionRateResult}' )
Then to assign it to a property depends on multiple things: 1) where are you doing it from, and 2) where do you want the property assigned.
To crawl the hierarchy from a script step, you would do something like:
testRunner.testCase.setPropertyValue("property_name", conversionRateResult)
Consider browsing through the documentation and API.
I'm working with https://adwords.google.com/api/adwords/mcm/v201402/ManagedCustomerService and wanting to get the account hierarchy.
The requests are being made in raw XML (controlled by JScript) -- a bit perverse, I know, but that's the situation.
I've generated the following SOAP packet
<?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:Header>
<ns1:RequestHeader soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="https://adwords.google.com/api/adwords/mcm/v201402">
<ns1:clientCustomerId>some_ccid</ns1:clientCustomerId>
<ns1:developerToken>some_developer_token</ns1:developerToken>
<ns1:userAgent>GAS</ns1:userAgent>
<ns1:validateOnly>false</ns1:validateOnly>
<ns1:partialFailure>false</ns1:partialFailure>
</ns1:RequestHeader>
</soapenv:Header>
<soapenv:Body>
<get xmlns="https://adwords.google.com/api/adwords/mcm/v201402">
<serviceSelector>
<fields>Login</fields>
<fields>Customer</fields>
<fields>Name</fields>
<predicate>
<field>id</field>
<operator>GREATER_THAN</operator>
<values>0</values>
</predicate>
</serviceSelector>
</get>
</soapenv:Body>
</soapenv:Envelope>
Please note the idGREATER_THAN0. This is my naive way of getting everything.
I notice that the PHP GetAccountHierarchy.php has
// Create selector.
$selector = new Selector();
// Specify the fields to retrieve.
$selector->fields = array('Login', 'CustomerId', 'Name');
// Make the get request.
$graph = $managedCustomerService->get($selector);
This would seem to imply that no predicate has been defined. However, I'm a bit leery of doing that because the documentation says (yes, I do read the friendly manual), "predicates ContentsNotNull"
The response I get is
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ns2:ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/mcm/v201402" xmlns="https://adwords.google.com/api/adwords/cm/v201402">
<requestId>0004f553e08eaca00abc25900000893f</requestId>
<serviceName>ManagedCustomerService</serviceName>
<methodName>get</methodName>
<operations>0</operations>
<responseTime>141</responseTime>
</ns2:ResponseHeader>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>[QuotaCheckError.INVALID_TOKEN_HEADER # ]</faultstring>
<detail>
<ns2:ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201402" xmlns:ns2="https://adwords.google.com/api/adwords/mcm/v201402">
<message>[QuotaCheckError.INVALID_TOKEN_HEADER # ]</message>
<ApplicationException.Type>ApiException</ApplicationException.Type>
<errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="QuotaCheckError">
<fieldPath/>
<trigger/>
<errorString>QuotaCheckError.INVALID_TOKEN_HEADER</errorString>
<ApiError.Type>QuotaCheckError</ApiError.Type>
<reason>INVALID_TOKEN_HEADER</reason>
</errors>
</ns2:ApiExceptionFault>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
What am I doing incorrectly that I should get such a response?
BTW, if I do leave out the predicate or specify it with a null content, I still get the QuotaCheckError.INVALID_TOKEN_HEADER error.
A solution has been provided on the Adwords API google group. Working nicely now!
So i'm trying to fetch all the calendar event from office360.com . I am using ews to get the data. I sent a request of
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
Traversal="Shallow">
<ItemShape>
<t:BaseShape>AllProperties</t:BaseShape>
<t:BodyType>HTML</t:BodyType>
</ItemShape>
<ParentFolderIds>
<t:DistinguishedFolderId Id="calendar"/>
</ParentFolderIds>
</FindItem>
</soap:Body>
</soap:Envelope>
This soap request xml is not returning me the calendar message body but i get the subject and other data . What am i doing wrong here ? any help is appreciated.
The body needs to be retrieved in a separate call.
http://weblogs.asp.net/psperanza/archive/2008/03/18/getting-calendar-items-using-exchange-web-services.aspx
Or you can load the property first.
http://blogs.msdn.com/b/exchangedev/archive/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services.aspx
The second is easier but you need to define all properties you want back and if it is a lot, it can be a pain.
how to parse soap response data
<?xml version="1.0" encoding="utf-8" ?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sqltypes=
"http://schemas.microsoft.com/SQLServer/2001/12/SOAP/types"
xmlns:sqlmessage=
"http://schemas.microsoft.com/SQLServer/2001/12/SOAP/
types/SqlMessage"
xmlns:sqlresultstream=
"http://schemas.microsoft.com/SQLServer/2001/12/SOAP/types
/SqlResultStream"
xmlns:tns="http://server/nwind2/soap"
<SOAP-ENV:Body>
<tns:MethodNameResponse>
<tns:OutputParam>Error Code 1152</tns:OutputParam>
</tns:MethodNameResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I expected the response data will be simple xml format, but the response is in soap-env.
how to parse the soap envelop xml data?
Is in soap-envelop format xml parsing is same has simple xml data parse?
example:Simple XML
<?xml version="1.0" encoding="utf-8" ?>
<error >Error Code 1152 </error>
#all Any one advice me how to parse this kind on xml
Thanks in advance.
This is wsdl web services. You can use http://sudzc.com/ which will generate Objective C stubs for you.