avoiding prefixes with java-ws and apache cfx - web-services

I'm using jax-ws with apache cxf every things seems ok , except the prefix in soap envelope
It looks like this now
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:CreateCustomer xmlns:ns2="http://tempuri.org">
<ns2:myVar>
</ns2:myVar>
<ns2:CreateCustomer xmlns:ns2="http://tempuri.org">
I'm trying to avoid the prefixes but keep the xmlns to look like this ...
<CreateCustomer xmlns="http://tempuri.org/">
<myVar>

Related

Importing the wsdl file in postman

I am trying to access the client URL web service in postman. I used the import link to import the wsdl file client URL in postman and successfully generated the collection. However, upon testing the request, I am unable to retrieve the data from the client server. I am only getting an empty element in the response body. I followed some of the SOAP Web Service tutorial on youtube and it is still the same. The client provided me the valid username for me to test but still the same.
This is my request body:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<zhi_sa_mgt xmlns="urn:mss:jfnllns:df">
<P_DATE>2022-10-22</P_DATE>
<P_NAME>
<item>HPOITY</item>
</P_NAME>
</zhi_sa_mgt>
</soap:Body>
</soap:Envelope>
And the response body:
<?xml version="1.0" encoding="utf-8"?>
<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>
<zhi_sa_mgt xmlns="urn:mss:jfnllns:df">
<P_DATA/>
</zhi_sa_mgt>
</soap:Body>
</soap:Envelope>
I just wanted to ask, what could be the possible reason/s on why I am getting the empty tag <P_DATA>? This is my first SOAP web service task and I cannot figure out why I cant retrieve the data from the client server. Thank you in advance for your response.

Including a CDATA field in a Service Connector

An API I am communicating with is Soap based and requires XML with inner XML (CDATA) in the request.
For the service connector action test I have hard-coded the inner xml with this format:
<![CDATA[
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationCrossReferenceId="123">
...
...
</Application> ]]>
where the dots indicate the data contained.
When running the test the request payload has been transformed to the html entity for < which is $lt; - as seen below :
Is there a way to avoid this?
This is a bug in Informatica. the other characters are decoded back to their original correctly, as described in KB 512858, &gt and &lt however are not decoded.
A bug report has been raised 29.05.2020.
Edit: Further investigation revealed that using CDATA was not necessary in my case, instead I was able to use the following input for the body binding:
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationCrossReferenceId="123">
...
...
</Application>

WSO2 Proxy service XML Xpath

Im using wso2 EI 6.5.0
in my proxy service i need to get element between these 2 tags <aa></aa>
xpath //tem:Request is working but /tem:Request/xDoc/aa does not work
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Request>
<xDoc>
<aa>
<bb>
....
</bb>
<cc>
<Parameter>
......
</Parameter>
</cc>
</aa>
</xDoc>
</tem:Request>
</soapenv:Body>
</soapenv:Envelope>
You have to use either /soapenv:Envelope/soapenv:Body/tem:Request/xDoc/aa or $body/tem:Request/xDoc/aa.
The purpose of using "//" in an xpath is to directly access a particular element. But if we use "/", we need to specify the entire path to traverse through the XML tags and reach a particular element.
On a different note, if you want to access the tag <aa/> then you can directly use the xpath //aa.

WSO2ESB, XPath, split values based on a token in SOAP response

I have a SOAP response message which contains a node value
similar to string A_B_C_D. I need to split each
value based on the underscore (_) and set them in
separate properties.
I checked with Xpath tokenize function but could not find a
way to get the values like array[1], array[2].. separately.
I also did some reading on XSLT mediator but not sure whether
it will help me to achieve this.
Please guide me on how to achieve this objective
Thanks
You can get value like "array[1]" but can't apply tokenize directly on soap:Body with ESB 4.8.1 :
<property xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fn="http://www.w3.org/2005/xpath-functions" name="MY_VALUE" expression="//soapenv:Body/myNode"/>
<property xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fn="http://www.w3.org/2005/xpath-functions" name="Element1" expression="fn:tokenize(syn:get-property('MY_VALUE'),'_')[1]"/>
With this message :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<myNode>A_B_C</myNode>
</soapenv:Body>
</soapenv:Envelope>
property 'Element1' contain : 'A'

Sending a SOAP Call

I'm learning how to send and receive a SOAP call. I have the required parameters available with me like username , password and the URL of the WSDL/WebService.I lso know a sample SOAP reply that I'm expecting which is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 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:Body>
<ns1:infoLookupResponse xmlns:ns1="urn:vtsPhoneNumberLookup">
<phoneNumber xsi:type="xsd:string">4444444444</phoneNumber>
<Type xsi:type="xsd:string">Landline</Type>
<OCN xsi:type="xsd:string">2222</OCN>
<OVERALLOCN xsi:type="xsd:string">2103</OVERALLOCN>
<COMPANY xsi:type="xsd:string">ABC Inc</COMPANY>
<DBA xsi:type="xsd:string">ABC Inc</DBA>
<CommonName xsi:type="xsd:string">ABC</CommonName>
<HOLDINGCOMPANY xsi:type="xsd:string">ABC Communications Inc</HOLDINGCOMPANY>
<MANAGEMENT xsi:type="xsd:string"></MANAGEMENT>
<SMS xsi:type="xsd:string"></SMS>
</ns1:infoLookupResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I have gone through online stuff and based on my understanding, in order to send the SOAP request, I need to have a raw XML of the same format that I'm
expecting ( as mentioned above). The condition in my case is that a user will be submitting a phone number using an HTML Page and that will be sent as a SOAP
request expecting the aforementioned reply from the server.
In the above case, a user would have submitted 4444444444 as a phone number. So,I understand that I need to create raw XML type of phoneNumber and my questions is, do I need to create raw XML for Type,OCN,OVERALLOCN,COMPANY,DBA,CommonName,HOLDINGCOMPANY,MANAGEMENT and SMS as well?
Please let me know if there is anything wrong with what I have understood so far. Also, let me know if you would like me to paste some specific part of WSDL which will help you in answering/understanding my question.