Use SoapUI to transfer byte[] is Possible? - web-services

I'm trying to pass a byte [] through the SoapUI program. Is it possible to do this? Or should I modify the soap and pass the data in another way for me to work?
If it is possible, how can I do it ?, and in case it is not possible in which you recommend me to match the byte []

Related

How to pass response values to Java API from Karate

How can I pass values from Karate API to Java class?
As mentioned in the documentation, I used the following code snippet to get the response from Java API. But its returning the response with un-formatted JSON content.
Map<String, Object> result = CucumberRunner.runClasspathFeature("demo/java/from-java.feature", args, true);
And then, I used the following script to print the response.
for(Map.Entry<String , Object> entry: getMbrWksMembershipDetailsResponse.entrySet())
{
if (entry.getKey().equalsIgnoreCase("response"))
{
System.out.println(entry.getValue());
}
}
It shows like,
{soap:Envelope={_={soap:Body={ns1:getMbrWksMembershipDetailsResponse={_={ns4:WksMembershipSummaryResponse={_={ns2:customerSummary={ns2:address={ns2:city=SOUTH CHESTERFIELD, ns2:country=USA, ns2:isoCountryCode=US, ns2:line1=9998, N. MICHIGAN ROAD., ns2:postalCode=23834, ns2:state=VA}, ns2:allowPasswordChange=true, ns2:arpMember=false, ns2:brandCode=RCI, ns2:brandId=1, ns2:companyCode=RCI, ns2:eliteMemberRewardStatus=false, ns2:eliteRewardStatus=true, ns2:europePointsClubMember=false, ns2:firstName=FRANK, ns2:homePhone=804/733-3004, ns2:isoCurrencyCode=USD, ns2:isoLanguageCode=EN, ns2:language=EN, ns2:lastName=BROWNING B, ns2:locale=en_US, ns2:memberDeveloperRenewed=false, ns2:memberEnrolledDate=2009-10-26T00:00:00-04:00, ns2:memberEnrolledForDirectDebit=false, ns2:memberEnrolledForPltDirectDebit=false, ns2:memberStatus=A, ns2:middleName=B, ns2:msgTranslationLanguageCode=EN, ns2:officePhone=0/-0, ns2:pointsCurrencyCode=0......
So it's little difficult to split the data based on the fields / tags from Map.
Please suggest what is the best option to get the values field wize / tag wise from Java API.
Thanks.
Yes, XML is internally held as a strange Map structure, refer to the section on type-conversion to understand more.
You have a simple way to do this. Just define a new variable that is the response converted to a string.
* xmlstring responseXml = response
After this you just need to get the responseXml out of the Map returned by the Java API which will be a string.
Note: don't use the Java API unless you are really trying to mix Karate with something else. The whole point of Karate is to avoid using Java for testing JSON and XML web-services.

spring web services -how do I get the string payload in a method endpoint?

How can I get the incoming XML payload as a String parameter in spring ws endpoint method?
For e.g. I have the following code, notice that I get the XML as a JDOM Element, which I now need to convert to String manually. It would be nice to know how to get this automatically converted to String.
#PayloadRoot(namespace=HOLIDAY_NAMESPACE_URI, localPart="holidayRequest")
#ResponsePayload
public Element handleHolidayRequest(#RequestPayload Element holidayRequest)
//public Element handleHolidayRequest(#XPathParam("holidayRequest") String holidayRequest)
{
System.out.println("In handleHolidayRequest method with payload: " + holidayRequest);
return getHolidayResponse(HOLIDAY_NAMESPACE);
}
The commented out method signature, is just me trying out XPath, which also did not work in the way I expected.
I was about to say that you should try to solve this by using an XPathParam annotation instead, but I see you've already tried that. Why didn't that work for you?
I'm not sure if you need the value of an element as a string or if you need the complete XML as a String. For the latter, you can try adding MessageContext to your method signature and use that to get the PayLoadSource as a string by using something like:
DOMSource source = (DOMSource) messageContext.getRequest().getPayloadSource();

Webservice Data Structures

I'm trying to Consume one SOAP webservice with SOAPUI and VB.NET to test.
But I can't understand one of the substructs SION_O_0010, it only show :
(...)
<SION_O_0009>aa</SION_O_0009>
<SION_O_0010 xsi:type="SI:SION_O_0010"/>
<SION_O_0011></SION_O_0011>
(...)
How Can I get the inner structure of SION_O_0010?
Regards,
Pedro
That element is empty. There is no inner structure.

How to send date as a parameter to the request in Ksoap2 to consume .Net web service

I am using KSoap2 for consume web service in my application. I need to send date as parameter in the request.
Can anybody know how to send date as a parameter and send the request and please give the sample code for it.
Does Ksoap2 support date format?
Thanks
It has worked best for me to format the date into a string and pass it through the webservice as a string. When receiving a string you just parse the string for a date. Keep in mind that you will have to know what format the date should be formatted as.
For automatic marshalling you can also get date to work, although you might have to implement a marshaller that support the format you need for your webservice. See the Float example in the ksoap2-android code base.
I am using the KSOAP2-android library. It already has a MarshalDate class that you just need to register to your SoapSerializationEnvelope.
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.setOutputSoapObject(soapRequest);
soapEnvelope.dotNet = true;
new MarshalDate().register(soapEnvelope); //This will enable you to pass a Date object as a parameter to your web service
You need to tell KSOAP how to serialize and deserialize the date - for that you need to write a class that implements the Marshal interface and register the envelope for that Marshal. This also holds for other data types, such as double.
Here is a tutorial on how to do it:
Implementing KSOAP Marshal Interface

CXF - Webservice method with parameter type as Element

I am trying to develop SOAP based webservice using CXF. My requirement is to accept any XML data structure as method parameter and then the logic to parse/handle this data would be internally taken care by webservice (A generic webservice for accepting request).
Hence I want to declare the method parameter as either org.w3c.dom.Element or org.w3c.dom.Document. I tried declaring method with these types but it gave an error.
Can anyone please let me know how, I can achieve this? I dont want to use REST approach.
Would a Provider based service work? Alternatively, make the method param a DOMSource or just Source. That may work better.