SoapUI response parsing for property transfer - xml-parsing

I have a soap response containing transaction ID (TranId).
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m0="http://schemas.blablabla.com/two/1.0/filter.xsd" xmlns:m="http://schemas.blablabla.com/two/1.0/filter.wsdl">
<SOAP-ENV:Body>
<m:AcctDebitRp xmlns:m="http://schemas.blablabla.com/two/1.0/filter.xsd">
<Response Response="1" TranId="**30538801**" Ver="14.3" Product="filter">
<m0:ApprovalCode>557885</m0:ApprovalCode>
</Response>
</m:AcctDebitRp>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
How can I retrieve transaction id value ?
I am using the below code in SoapUI property transfer step to retrieve the value of ApprovalCode:
declare namespace ns1='http://schemas.blablabla.com/two/1.0/filter.xsd';
//ns1:ApprovalCode
Is it possible to get the TranId value using XQuery in property transfer step or using groovy script step?

You can query for attributes using an #attributename child step. In the example you provided, the <Response/> element has no namespace attached, thus the query for the attribute is a simple
//*:Response/#TranId
If you only want the attribute value, consider applying the data(...) function:
data(//*:Response/#TranId)

Related

Not able to validate xpath from soap api response

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

Bing Ads API Reporting Service returns error code 2015 "No Dimension Selected"

I'm trying to pull some data from the Bing Ads API but I keep getting error code 2015. I'm using Savon with Ruby on Rails. Here is the request:
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/Reporting/v13" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns="https://bingads.microsoft.com/Reporting/v13">
<env:Header>
<AuthenticationToken>blahblahblah</AuthenticationToken>
<CustomerAccountId>blahblahblah</CustomerAccountId>
<CustomerId>blahblahblah</CustomerId>
<DeveloperToken>blahblahblah</DeveloperToken>
</env:Header>
<env:Body>
<tns:SubmitGenerateReportRequest>
<ReportRequest xsi:nil="false" xsi:type="AccountPerformanceReportRequest">
<ExcludeColumnHeaders>true</ExcludeColumnHeaders>
<ExcludeReportFooter>true</ExcludeReportFooter>
<ExcludeReportHeader>true</ExcludeReportHeader>
<Format>Csv</Format>
<Language>English</Language>
<ReportName>AccountPerformanceReportRequest</ReportName>
<ReturnOnlyCompleteData>false</ReturnOnlyCompleteData>
<Aggregation>Summary</Aggregation>
<Columns>
<AccountPerformanceReportColumn>Spend</AccountPerformanceReportColumn>
<AccountPerformanceReportColumn>Clicks</AccountPerformanceReportColumn>
<AccountPerformanceReportColumn>Conversions</AccountPerformanceReportColumn>
<AccountPerformanceReportColumn>Revenue</AccountPerformanceReportColumn>
</Columns>
<Filter xsi:nil="true"/>
<Scope>
<AccountIds xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a1:long>blahblahblah</a1:long>
</AccountIds>
</Scope>
<Time>
<CustomDateRangeEnd>
<Day>02</Day>
<Month>04</Month>
<Year>2019</Year>
</CustomDateRangeEnd>
<CustomDateRangeStart>
<Day>01</Day>
<Month>04</Month>
<Year>2019</Year>
</CustomDateRangeStart>
<PredefinedTime xsi:nil="true"/>
<ReportTimeZone>EasternTimeUSCanada</ReportTimeZone>
</Time>
</ReportRequest>
</tns:SubmitGenerateReportRequest>
</env:Body>
</env:Envelope>
As you can see, I'm pulling the report with 'Summary' as the aggregation type. If I use 'Monthly' as the aggregation type and include a 'TimePeriod' column, it works perfectly, but if I do that then the data returned is for the whole month of April as opposed to the date range I've selected 04-01-2019..04-02-2019.
Here is the response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Server</faultcode>
<faultstring xml:lang="en-US">Invalid client data. Check the SOAP fault details for more information</faultstring> <detail>
<ApiFaultDetail xmlns="https://bingads.microsoft.com/Reporting/v13" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<TrackingId xmlns="https://adapi.microsoft.com">52665fe5-3eb8-42e0-ad8e-942e848297ce</TrackingId>
<BatchErrors/>
<OperationErrors>
<OperationError>
<Code>2015</Code>
<Details>No Dimension selected.</Details>
<ErrorCode>RequiredColumnsNotSelected</ErrorCode>
<Message>The specified report request does not specify all the required columns for this report type. Please submit a report request with the required columns for this report type, and optionally additional columns that are to be included in the report.</Message>
</OperationError>
</OperationErrors>
</ApiFaultDetail>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
The error code returned would lead me to believe that a TimePeriod column is required even for Summary, but that contradicts what is documented here.
All other aggregation types work with this setup. Any help would be greatly appreciated.
Good catch. We will update documentation to clarify that at least one attribute (non performance stat) e.g., AccountId must be included. Most of the other reports have specific attributes that must be included, whereas the account report does not. I hope this helps!

Access fields from an http response by parsing the response

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

XSD validation fails with UndeclaredPrefix when using AxiomSoapMessageFactory in Spring WS

I'm building a contract-first SOAP web service with spring-ws 2.2.3. My XML Schema uses extensions, leading to xsi:type= attributes in the XML requests. Since some respones can be very large (30MB), I'm using a AxiomSoapMessageFactory instead of the default SaajSoapMessageFactory, as suggested in the Spring WS docs. I validate incoming requests with a PayloadValidatingInterceptor:
PayloadValidatingInterceptor interceptor = new PayloadValidatingInterceptor();
interceptor.setSchema(new ClassPathResource("format-service.xsd"));
interceptor.setValidateRequest(true);
interceptor.setValidateResponse(false);
My problem is that I get spurious validation errors, depending on where in the XML the namespace is declared: if it's declared in the payload, then everything works fine:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header/>
<soapenv:Body>
<sch:formatRequest xmlns:sch="http://example.com/springws/extension/schema">
<sch:value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="sch:currencyType">
<sch:amount>1000</sch:amount>
<sch:currency>EUR</sch:currency>
</sch:value>
</sch:formatRequest>
</soapenv:Body>
</soapenv:Envelope>
But as soon as I move the sch namespace declaration up to the Envelope:
<soapenv:Envelope xmlns:sch="http://example.com/springws/extension/schema" ...>
validation fails and I receive a SOAP Fault:
<faultcode>soapenv:Client</faultcode>
<faultstring xml:lang="en">Validation error</faultstring>
<detail>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">UndeclaredPrefix: Cannot resolve 'sch:currencyType' as a QName: the prefix 'sch' is not declared.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-elt.4.1: The value 'sch:currencyType' of attribute 'http://www.w3.org/2001/XMLSchema-instance,type' of element 'sch:value' is not a valid QName.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-type.2: The type definition cannot be abstract for element sch:value.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">UndeclaredPrefix: Cannot resolve 'sch:currencyType' as a QName: the prefix 'sch' is not declared.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-attribute.3: The value 'sch:currencyType' of attribute 'xsi:type' on element 'sch:value' is not valid with respect to its type, 'QName'.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-complex-type.2.1: Element 'sch:value' must have no character or element information item [children], because the type's content type is empty.</spring-ws:ValidationError>
</detail>
It appears like a bug in the AxiomSoapMessageFactory / Axiom implementation to me (namespace context is lost), as both requests validate fine when using the SaajSoapMessageFactory. Note that the validation only fails on the xsi:type= attribute. The same namespace is recognized correctly for elements.
I cannot use SaajSoapMessageFactory due to high memory consumption for large responses. I found similar problems described in the Spring forum and on SO, but no solution. Thanks for help!
The reason is that Spring-WS uses OMContainer#getXMLStreamReader(). Instead it should use OMContainer#getXMLStreamReader(boolean, OMXMLStreamReaderConfiguration) and set the preserveNamespaceContext property to true in the OMXMLStreamReaderConfiguration object.
You should file a bug for Spring-WS, or even better, fix the issue and submit a pull request.

Is this normal behavior for Yahoo PlaceFinder API? Seems odd to me

So I have this lat/lng pair, 39.905983/116.459373. Forever, the PlaceFinder API has been returning WOE ID 2151399 for this. Then suddenly it stopped, and started returning null (empty) instead.
I thought maybe the service was remembering that it had already done this for my API key, so I switched to another one. Still, null WOE ID. It makes sense because it is still processing other lat/lng pairs which I have also queried excessively during development.
I changed the values sent to the PlaceFinder query to 39.9059830001/116.4593730001 (just added 0001 to the end of each), and it started returning the WOE ID again.
My question: What gives?
I tried the same query using PlaceFinder via the YQL Console:
select woeid from geo.placefinder where text="39.905983,116.459373" and gflags="R"
...and get the same WOEID result you mentioned:
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="1" yahoo:created="2012-03-20T16:24:40Z" yahoo:lang="en-US">
<results>
<Result>
<woeid>2151399</woeid>
</Result>
</results>
</query>
I have not seen the behavior you mentioned, so I would consider it not normal. In the case where a null value is returned, do you have the normal HTTP status code? You might be running into a rate limit.

Resources