XML SOAP XML format that maps to Map<String, String> - soap

Due to restraints to access to change of SOAP client, I have to change the output format of the SOAP produced by my API: I need to make the Java client, which uses Axes call.invoke and return Map<String, String>. How can I make the output below parsable Map<String, String>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<promoteDemotePartResponse xmlns="http://DefaultNamespace">
<promoteDemotePartReturn xmlns="http://xml.apache.org/xml-soap">
<item>
<status>Success</status>
<objectAction>checkin</objectAction>
</item>
</promoteDemotePartReturn>
</promoteDemotePartResponse>
</soapenv:Body>
</soapenv:Envelope>
What can I change in my xml output to make it work with unchangeable Java client.
I have access to change the format of the XML. I can only retrieve one value

Related

Do we have any SOAP API or REST API which will give us response/metadata with custom form and its fields

I am trying to get the metadata/fields of the custom forms in Netsuite. But the documentation of netsuite does not provide any direct way of doing this. Some pages mentioned using the SOAP Api's, So i tried using the SOAP api. Here is my api request in SOAP.
<?xml version="1.0"?>
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soapenv:Header>
<ns1:searchPreferences
xmlns:ns1="urn:messages_2022_1.platform.webservices.netsuite.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
<ns1:pageSize>30</ns1:pageSize>
</ns1:searchPreferences>
<ns2:tokenPassport soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0"
xmlns:ns2="urn:messages_2022_1.platform.webservices.netsuite.com">
<ns3:account
xmlns:ns3="urn:core_2022_1.platform.webservices.netsuite.com">{{ACCOUNT}}
</ns3:account>
<ns4:consumerKey
xmlns:ns4="urn:core_2022_1.platform.webservices.netsuite.com">{{CONSUMER_KEY}}
</ns4:consumerKey>
<ns5:token
xmlns:ns5="urn:core_2022_1.platform.webservices.netsuite.com">{{TOKEN_ID}}
</ns5:token>
<ns6:nonce
xmlns:ns6="urn:core_2022_1.platform.webservices.netsuite.com">{{nonce}}
</ns6:nonce>
<ns7:timestamp
xmlns:ns7="urn:core_2022_1.platform.webservices.netsuite.com">{{timestamp}}
</ns7:timestamp>
<ns8:signature
xmlns:ns8="urn:core_2022_1.platform.webservices.netsuite.com" algorithm="HMAC-SHA256">{{signature}}
</ns8:signature>
</ns2:tokenPassport>
</soapenv:Header>
<soapenv:Body>
<getSelectValue>
<fieldDescription
xmlns:platformCore="urn:core_2022_1.platform.webservices.netsuite.com">
<platformCore:recordType>salesOrder</platformCore:recordType>
<platformCore:sublist
xmlns="urn:core_2022_1.platform.webservices.netsuite.com">customForm
</platformCore:sublist>
<platformCore:field>salesOrder</platformCore:field>
<platformCore:filterByValueList>
<platformCore:filterBy>
<platformCore:field>entity</platformCore:field>
<platformCore:internalId>164</platformCore:internalId>
</platformCore:filterBy>
</platformCore:filterByValueList>
</fieldDescription>
<pageIndex>1</pageIndex>
</getSelectValue>
</soapenv:Body>
</soapenv:Envelope>
The authorization and the signature generation are working correctly and it return actual response from netsuite. The response contains the list of all custom forms, but not the metadata/fields of the form i put in the filter part.
If there is any other way to do this let me know.

What are Servicenow SOAP API getkeys wildcards?

I'd like to use a SOAP request to get a list of items in servicenow table, that have description starting with "TEST".
I am able to send a simple getKeys request. For example the below one is successfully returning to me the sys_id of a single ticket:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hr="http://www.service-now.com/hr_case">
<soapenv:Header/>
<soapenv:Body>
<hr:getKeys>
<short_description>TEST Soap 1</short_description>
</hr:getKeys>
</soapenv:Body>
</soapenv:Envelope>
How should I modify the above request, so that it returns keys of all items with description starting with "TEST"?
I've used instead a REST webservice with the URI:
https://???.service-now.com/api/now/table/hr_case?sysparm_query=short_descriptionSTARTSWITHTEST
before then I tried a URI like that:
https://???.service-now.com/api/now/table/hr_case?&short_description=TEST Soap 1

How to access body of payload for a camel-cxf endpoint

I have my CXF based Jax-WS webservice and trying to read Payload of request.
I have org.apache.camel.component.cxf.CxfEndpoint whose Dataformat I am setting to Payload.
I am making call to this Service with POST method with body as Soap envelope as follows.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:loc="http://www.csapi.org/schema/parlayx/terminal_location/v2_0/local">
<soapenv:Header/>
<soapenv:Body>
<loc:getLocation>
<loc:address>tel:+948420161525</loc:address>
<loc:requestedAccuracy>500</loc:requestedAccuracy>
<loc:acceptableAccuracy>500</loc:acceptableAccuracy>
</loc:getLocation>
</soapenv:Body>
</soapenv:Envelope>
Here body is representation of GetLocation object of ParlayX protocol.
In my class, I receive CxfPayload object. I want to retrieve address and requestedAccuracy from the Payload body.
I tried to extract required data from getBodySources() and getBody() methods of CxfPayload. But could not succeed. I don't see the required data in the object.
I referred some examples from link but could not succeed too.
Any idea how I can extract body data of payload ?
There are a few ways you can do this. For example you can unmarshal it into a POJO and access it using Java methods. Or if you just want a few values from the payload, you can simply use XPath:
<setHeader headerName="address">
<xpath>//loc:address/text()</xpath>
</setHeader>
Which sets the address in the address header.
Edit:
To use xpath on your payload in Java, something like this should do the trick:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(BODY_IN_STRING)));
XPath xPath = XPathFactory.newInstance().newXPath();
String address = xPath.evaluate("//loc:address/text()", document));

How to get response value from Currency Converter service response through groovy script in SoapUI?

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.

java.lang.Object over a MULE SOAP Component

I need to pass to soap component an object of a known class which is composed from two strings.
the soap request should be like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsd="http://wsTest/">
<soapenv:Header/>
<soapenv:Body>
<wsd:find>
<entity>
<id>string_1</id>
<type>string_2</type>
</entity>
</wsd:find>
</soapenv:Body>
</soapenv:Envelope>
Is there a suitable MULE transformer where I can input the two Strings then convert them to the wanted class object ??
thank you.
Use an expression transformer:
<expression-transformer expression="#[new com.mycomp.Entity('string_1','string_2')]" />
assuming the com.mycomp.Entity class has a two string constructor.