java.lang.Object over a MULE SOAP Component - soap

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.

Related

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

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

SuiteTalk SOAP API TransactionSearchBasic with type journalEntry fails

I tried fetching all the journal entries in my account using the SuiteTalk SOAP API.
But it fails with the message
The field type's enum value <journalEntry> is invalid for this
search.
The Request and Response are as follows:
==================== Beginning of Request ====================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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:searchPreferences xmlns:ns1="urn:messages_2021_1.platform.webservices.netsuite.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
<ns1:pageSize>20</ns1:pageSize>
</ns1:searchPreferences>
<ns2:tokenPassport xmlns:ns2="urn:messages_2021_1.platform.webservices.netsuite.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
<ns3:account xmlns:ns3="urn:core_2021_1.platform.webservices.netsuite.com">#####</ns3:account>
<ns4:consumerKey xmlns:ns4="urn:core_2021_1.platform.webservices.netsuite.com">#####3</ns4:consumerKey>
<ns5:token xmlns:ns5="urn:core_2021_1.platform.webservices.netsuite.com">#####</ns5:token>
<ns6:nonce xmlns:ns6="urn:core_2021_1.platform.webservices.netsuite.com">#####</ns6:nonce>
<ns7:timestamp xmlns:ns7="urn:core_2021_1.platform.webservices.netsuite.com">#####</ns7:timestamp>
<ns8:signature xmlns:ns8="urn:core_2021_1.platform.webservices.netsuite.com" algorithm="HMAC-SHA256">#####</ns8:signature>
</ns2:tokenPassport>
</soapenv:Header>
<soapenv:Body>
<search xmlns="urn:messages_2021_1.platform.webservices.netsuite.com">
<searchRecord xmlns:ns9="urn:common_2021_1.platform.webservices.netsuite.com" xsi:type="ns9:TransactionSearchBasic">
<ns9:type xmlns:ns10="urn:core_2021_1.platform.webservices.netsuite.com" operator="anyOf" xsi:type="ns10:SearchEnumMultiSelectField">
<ns10:searchValue xsi:type="xsd:string">journalEntry</ns10:searchValue>
</ns9:type>
</searchRecord>
</search>
</soapenv:Body>
</soapenv:Envelope>
==================== End of Request ====================
==================== Beginning of Response ====================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
<platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2021_1.platform.webservices.netsuite.com">
<platformMsgs:nsId>#####</platformMsgs:nsId>
</platformMsgs:documentInfo>
</soapenv:Header>
<soapenv:Body>
<searchResponse xmlns="urn:messages_2021_1.platform.webservices.netsuite.com">
<platformCore:searchResult xmlns:platformCore="urn:core_2021_1.platform.webservices.netsuite.com">
<platformCore:status isSuccess="true">
<platformCore:statusDetail type="WARN">
<platformCore:code>WARNING</platformCore:code>
<platformCore:message>The field type's enum value <journalEntry> is invalid for this search.</platformCore:message>
</platformCore:statusDetail>
</platformCore:status>
<platformCore:totalRecords>0</platformCore:totalRecords>
<platformCore:totalPages>0</platformCore:totalPages>
<platformCore:searchId>#####a</platformCore:searchId>
<platformCore:recordList/>
</platformCore:searchResult>
</searchResponse>
</soapenv:Body>
</soapenv:Envelope>
==================== End of Response ====================
The permissions for the role are as follows:
You should use the TransactionType enum ex in java:
SearchEnumMultiSelectField searchTypeValue = new SearchEnumMultiSelectField();
searchTypeValue.getSearchValue().add(TransactionType.JOURNAL.value());
The search type string should be "_journal":
<search xmlns="urn:messages_2021_1.platform.webservices.netsuite.com">
<searchRecord xmlns:ns9="urn:common_2021_1.platform.webservices.netsuite.com" xsi:type="ns9:TransactionSearchBasic">
<ns9:type xmlns:ns10="urn:core_2021_1.platform.webservices.netsuite.com" operator="anyOf" xsi:type="ns10:SearchEnumMultiSelectField">
<ns10:searchValue xsi:type="xsd:string">_journal</ns10:searchValue>
</ns9:type>
</searchRecord>
</search>
See https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2021_1/schema/enum/transactiontype.html?mode=package and https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2021_1/schema/search/transactionsearchbasic.html?mode=package
You should always use the Schema Browser to look these things up, since they can be different between different uses.
Depending on how you are generating the SOAP message, how you get the string can vary. If using C#, Visual Studio, and the proxy classes created from the WSDL, there should be an enum that gets you the right string values.
EDIT:
Specifically, the values are stored in a public enum called RecordType. In C#, RecordType.JournalEntry (which has an integer value of 94) will place "_journal" in the SOAP message.

How to use mutiple values in input parameters in soap call

I have a current requirement where I need to make a soap call to retrieve the data for further business intelligence. I have no experience in SOAP.
The service call is called getSiteInfo.
getSiteInfo has following 4 parameters- userName, password, custNbr, siteId.
Now I can make calls like this and it generates an xml response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bil="http://billing.xyz.cc/">
<soapenv:Header/>
<soapenv:Body>
<bil:getSiteInfo>
<!--userName:-->
<arg0>username</arg0>
<!--password:-->
<arg1>pswd</arg1>
<!--custNbr:-->
<arg2>288</arg2>
<!--siteId:-->
<arg3>0862578</arg3>
</bil:getSiteInfo>
</soapenv:Body>
</soapenv:Envelope>
I was wondering is it possible to include multiple siteId in the same call instead of doing it repeatedly for almost 1000+ siteIds.
I tried the following two to see if they work and none of them did. It only returned the response for the last item; 108952 in this case.
Method1
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bil="http://billing.xyz.cc/">
<soapenv:Header/>
<soapenv:Body>
<bil:getSiteInfo>
<!--userName:-->
<arg0>username</arg0>
<!--password:-->
<arg1>pswd</arg1>
<!--customerNumber:-->
<arg2>288</arg2>
<!--siteNumber:-->
<arg3>0862578</arg3>
<arg3>108952</arg3>
</bil:getSiteInfo>
</soapenv:Body>
</soapenv:Envelope>
Method2
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bil="http://billing.xyz.cc/">
<soapenv:Header/>
<soapenv:Body>
<bil:getSiteInfo>
<!--userName:-->
<arg0>username</arg0>
<!--password:-->
<arg1>pswd</arg1>
<!--customerNumber:-->
<arg2>288</arg2>
<!--siteNumber:-->
<arg3>108952</arg3>
</bil:getSiteInfo>
<bil:getSiteInfo>
<!--userName:-->
<arg0>username</arg0>
<!--password:-->
<arg1>pswd</arg1>
<!--customerNumber:-->
<arg2>288</arg2>
<!--siteNumber:-->
<arg3>0862578</arg3>
</bil:getSiteInfo>
</soapenv:Body>
</soapenv:Envelope>
Thank you very much in advance.

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.

Groovy variable in SoapUI MockResponse Attribute

I'm trying to get the current datetime in an attribute for a MockResponse in SoapUI.
What I've tried is:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:localns">
<soapenv:Header/>
<soapenv:Body>
<response instant="${=new java.text.SimpleDateFormat('yyyy-MM-dd'T'HH:mm:ssZ').format(new Date())}"/>
</soapenv:Body>
</soapenv:Envelope>
I've also tried it without the quotes around the variable, but it doesn't work.
I've seen plenty of examples for using variables as a text node, but not as an attribute, how do I do this?
EDIT The only way to get it to work was to declare a variable in the script below and pass that one to my attribute. This way, the quotes didn't get confused with each other.
Try:
<response instant="${new Date().format( 'yyyy-MM-dd'T'HH:mm:ssZ' )}"/>