How to change the way coldfusion send the soap response? - web-services

I have a coldfusion webservice which takes in XML data and send back the acknowledgement.
When there is an error the current code returns me the soap response as
<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:Body>
<ns1:updatePendingTicketsResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://v02.intouchdataservice">
<updatePendingTicketsReturn xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><![CDATA[<fault>
<faultcode>TO BE DEFINED IF NEEDED</faultcode>
<faultstring >Content is not allowed in prolog.</faultstring>
<faultactor>InTouch</faultactor>
</fault>]]></updatePendingTicketsReturn>
</ns1:updatePendingTicketsResponse>
</soapenv:Body>
</soapenv:Envelope>
But what I would like to have in response is
<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:Body>
<soapenv:Fault>
<faultcode>TO BE DEFINED IF NEEDED</faultcode>
<faultstring >Content is not allowed in prolog.</faultstring>
<faultactor>InTouch</faultactor>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Is there a way we can change the way coldfusion sends back the response when there is an exception?
In addition to that, Is there a way we can add an XML schema to the coldfusion WSDL to validate the XML document thats been send ?
Thank you

I think no but you can put whole code in try and catch define your own response code.

You can use the wsdlfile attribute of <cfcomponent /> to specify a custom WSDL.
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7e0e.html
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-78a6.html

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.

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.

Salesforce soap error: not a valid value for the enum 'ExecutionLogType'

Can anyone help me with this? I can't find information anywhere about this error message.
I created a webservice class and i'm using SoapUI just to check if it's working and I keep getting the error below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>'' is not a valid value for the enum 'ExecutionLogType'</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
My input is below. I I don't know how to use the field Client or why it's generated in the wsdl, this field is not in my class.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:exec="http://soap.sforce.com/schemas/class/ExecutiveCareWebservice">
<soapenv:Header>
<exec:AllowFieldTruncationHeader>
<exec:allowFieldTruncation>FALSE</exec:allowFieldTruncation>
</exec:AllowFieldTruncationHeader>
<exec:DebuggingHeader>
<exec:categories>
<exec:category>ALL</exec:category>
<exec:level>DEBUG</exec:level>
</exec:categories>
<exec:debugLevel></exec:debugLevel>
</exec:DebuggingHeader>
<exec:CallOptions>
<exec:client>1</exec:client>
</exec:CallOptions>
<exec:SessionHeader>
<exec:sessionId>00D0E0000008dby!ASAAQBqFFnoPgI88ekHhKy4.N0aKNAw5sIR_1LSGSqzZ_cOg.4oH9hpyW1cB2JDC._BnMKu54FhiJ4p_ORUyIQf39MbRZoqs</exec:sessionId>
</exec:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<exec:getActiveClientes>
<exec:validationDate></exec:validationDate>
</exec:getActiveClientes>
</soapenv:Body>
</soapenv:Envelope>
Thanks in advance!
Joana
Simplify your soapenv:Header headers. I suspect the problem is with the exec:DebuggingHeader header. In particular, the exec:debugLevel is likely related to the ExecutionLogType.
Just leave that header out completely. In fact, the only header you should need is exec:SessionHeader

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'

How do I remove operation element from soap envelope body in WCF?

I have a WCF service setup mostly to a customer's spec, yet there is one extra element required of an envelope body that I'm trying to exclude based on the customer's sample request.
These are my service and operation contracts:
[ServiceContract(Namespace="http://www.somenamespace.com")]
public interface IProcessPayment
{
[OperationContract]
ResponseSubmitPayment execute(RequestSubmitPayment RequestSubmitPayment);
}
This is what they are sending to test my service with:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pay="http://www.somenamespace.com">
<soapenv:Header/>
<soapenv:Body>
<pay:RequestSubmitPayment>
<!-- irrelevant stuff -->
</pay:RequestSubmitPayment>
</soapenv:Body>
</soapenv:Envelope>
and this is what my service expects (based on SOAPUI):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pay="http://www.somenamespace.com">
<soapenv:Header/>
<soapenv:Body>
<pay:execute> <!-- I want to remove this! -->
<pay:RequestSubmitPayment>
<!-- irrelevant stuff -->
</pay:RequestSubmitPayment>
</pay:execute> <!-- I want to remove this! -->
</soapenv:Body>
</soapenv:Envelope>
How can I configure my WCF service to not require or exclude that element? The client has told me they have many other customers with it successfully tested and implemented. SOAP 1.1 is my understanding of what they're sending.
Thanks in advance!
Not sure it is doable in operationcontract. Try using a message contract, it will give you the flexibility you need. If that fails use an xmlserializer contract with method flag ParameterStyle = SoapParameterStyle.Bare.