I have a SOAP proxy service with a Data Mapper to create the output.
The created response does not have the soap envelope tag.
If I try to add the envelope with the payload factory, it strips out the envelope (but it keeps the Body element).
I'm using the WSO2 EI 6.4.0.
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="EstrattoContoEntiTributi" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
...
<send>
<endpoint key="..."/>
</send>
</inSequence>
<outSequence>
<datamapper .../>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
We need to use a property mediator as below.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="PF2"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsd="http://services.samples/xsd"
xmlns:ser="http://services.samples">
<soap:Header/>
<soap:Body>
<ser:getQuote>
<ser:request>
<xsd:symbol>IBM</xsd:symbol>
</ser:request>
</ser:getQuote>
</soap:Body>
</soap:Envelope>
</format>
<args/>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="text/xml"/>
<log level="full">
<property name="ChangedEnve" value="----Changed-------"/>
</log>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
Hope this helps,
https://medium.com/#isuruuy/how-to-construct-a-payload-with-the-soap-envelope-ce8df5032dda
Related
I working on WSO2 ESB profile for sap adapter. I followed the step for configuring sap adapter with WSO2 as mentioned in manual. But yet after starting the server, I am not able to create BapiSender proxy service in management console. It is marked default with the error
SAPTransportListener Unable to configure the service BAPISender for the BAPI transport: Service doesn't have configuration information for transport bapi. This service is being marked as faulty and will not be available over the BAPI transport.
WARN - SAPTransportListener Disabling the bapi transport for the service BAPISender, because it is not configured properly for the service.
Can you post your proxy service? Below you'll find a working example proxy.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="SAPProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<payloadFactory media-type="xml" description="BAPIPayload">
<format>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<bapirfc xmlns="" name="Z_CONVERT_IBAN_2_BANK_ACCOUNT">
<import>
<field name="I_IBAN">123456789</field>
</import>
</bapirfc>
</soap:Body>
</soap:Envelope>
</format>
<args/>
</payloadFactory>
<send>
<endpoint name="sap-endpoint">
<address uri="bapi:/yourconf"/>
</endpoint>
</send>
<log level="full">
<property name="step" value="--- AFTER SEND TO SAP 2 --"/>
</log>
</inSequence>
<outSequence>
<log level="full">
<property name="step" value="--- RESULT FROM SAP --"/>
</log>
<send/>
</outSequence>
<faultSequence>
<log level="full">
<property name="step" value="--- FAULT --"/>
</log>
<drop/>
</faultSequence>
</target>
<description/>
</proxy>
My requirement is to transform a JSON request to a XML format.
And I got the code which converts JSON to XML in the below URL.
https://isurugunawardana.com/2015/05/19/json-support-for-wso2-esb-class-mediator/
But i need to know how this is been called from a proxy service in WSO2 EI..
I have tried creating a proxy service which calls the class mediator.
'
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestClassMedProxy"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<log level="custom">
<property name="BEGIN" value="Begin Sequence"/>
</log>
<class name="org.anthem.caremore.JSONtoXML">
<property name="inputPath" value="5"/>
</class>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
`
I am using WSO2 ESB to send a JMS message (XML payload) to an endpoint and then to read a return JMS message (on another queue) from the same endpoint (which also sends an XML payload). The problem I am facing is that the return JMS message from the endpoint, even though it is an XML payload, comes in as a text message.
Here is what I see in WSO2 for the JMS message (with XML payload) sent back by the endpoint:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<axis2ns2:text xmlns:axis2ns2="http://ws.apache.org/commons/ns/payload">
<?xml version="1.0" encoding="UTF-8"?>
<Sys1Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Sys1-ack-nack.xsd">
<security>
<statusInfo>
<ARMStatus>ARM_ACK</ARMStatus>
<Sys1Status>Sys1_ACK</Sys1Status>
<FinalStatus>ACK</FinalStatus>
</statusInfo>
<upstreamIdentifier>
<tradeId>459609</tradeId>
<messageId>12345678</messageId>
<assetId>6M2</assetId>
<issueDescription>IRS RTP 3.12 19MAY11 JP</issueDescription>
<productType>SWAPTION</productType>
</upstreamIdentifier>
</security>
</Sys1Response>
</axis2ns2:text>
</soapenv:Body>
</soapenv:Envelope>
This is the WSO2 proxy definition.
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<registry provider="org.wso2.carbon.mediation.registry.ESBRegistry">
<parameter name="localRegistry">/</parameter>
<parameter name="cachableDuration">15000</parameter>
</registry>
<proxy name="ToWSO2"
transports="jms"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="transport.jms.ContentTypeProperty"
value="Content-Type"
scope="axis2"/>
<log level="full"/>
<call>
<endpoint>
<address uri="jms:/ToSys1?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue&transport.jms.ReplyDestinationType=queue&transport.jms.ReplyDestination=FromSys1&transport.jms.ContentType=application/xml"/>
</endpoint>
</call>
<log level="full"/>
</inSequence>
<outSequence>
<log level="full"/>
<drop/>
</outSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.Destination">ToWSO2</parameter>
</proxy>
<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<drop/>
</sequence>
<sequence name="main">
<in>
<log level="full"/>
<filter source="get-property('To')" regex="http://localhost:9000.*">
<send/>
</filter>
</in>
<out>
<send/>
</out>
<description>The main sequence for the message mediation</description>
</sequence>
</definitions>
Would appreciate help in resolving this. Many thanks in advance!
I configure two proxies in ESB, and these 2 proxies are bridged to one instance mediator. And I have different property set for mediator in proxy configuration.
I expect that the two mediators instances are running in ESB with different properties.
But in fact, seems only mediator instance is in ESB.
Any idea on this?
I made a mistake here. In java code, spring bean is used to contain mediator property configured in xml file. But spring bean is singleton and causes different configuration cannot be applied in different proxy.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="abc"
transports="http"
startOnLoad="true"
trace="enable"
statistics="enable">
<description/>
<target>
<inSequence>
<log level="full"/>
<property name="address"
scope="transport"
expression="fn:substring-after(get-property('To'),'/services/crownperth')"/>
<class name="com.abc.customerintegration.mediator.CustomerInfoMediator">
<property name="pmServerAddress" value="http://192.168.112.243:3509/MobileConnectService"></property>
<property name="property" value="P"/>
<property name="languageCode" value="en-US"></property>
</class>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="def"
transports="http"
startOnLoad="true"
trace="enable"
statistics="enable">
<description/>
<target>
<inSequence>
<log level="full"/>
<property name="address"
scope="transport"
expression="fn:substring-after(get-property('To'),'/services/crownperth')"/>
<class name="com.abc.customerintegration.mediator.CustomerInfoMediator">
<property name="pmServerAddress" value="http://192.168.112.243:3509/MobileConnectService"></property>
<property name="property" value="P"/>
<property name="languageCode" value="en-US"></property>
</class>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
i am new to wso2.. My requirement is
1) I want to transform incoming JSON request into XML format
2) Send that XML request to an external SOAP service
3) Response will get as XML and need to convert it into JSON format
Did somebody ever did that? If so, could you please share how you did?
I have the below configuration for a PROXY service
`<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="CelsiusToFahrenheitService"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="messageType" value="text/xml" scope="axis2"/>
<property name="Proxy-Authorization"
expression="fn:concat('Basic', base64Encode('INDIA\username:pwd'))"
scope="transport"/>
<property name="POST_TO_URI" value="true" scope="axis2"/>
<property name="DISABLE_CHUNKING" value="true" scope="axis2"/>
<header name="Action"
value="http://www.w3schools.com/webservices/CelsiusToFahrenheit"/>
<send>
<endpoint>
<address uri="http://www.w3schools.com/webservices/tempconvert.asmx"
format="soap11"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<property name="messageType" value="text/xml" scope="axis2"/>
<send/>
</outSequence>
</target>
<description/>
</proxy>`
XML Request
<CelsiusToFahrenheit xmlns="http://www.w3schools.com/webservices/">
<Celsius>20</Celsius>
</CelsiusToFahrenheit>
XMl Response
<CelsiusToFahrenheitResponse xmlns="http://www.w3schools.com/webservices/">
<CelsiusToFahrenheitResult>68</CelsiusToFahrenheitResult>
</CelsiusToFahrenheitResponse>
Need to send REQUEST as JSON and RESPOSNE also get as JSON
Can anyone please help me the scenario
How to use ScriptMediator to do the above proxy service. I have got sample from here (https://docs.wso2.org/display/ESB481/Sample+441%3A+Converting+JSON+to+XML+Using+JavaScript)
I have did my configuration like this (Don't know is it correct or not)
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JsonToXMLProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<script language="js">var cel= mc.getPayloadJSON().CelsiusToFahrenheit.Celsius.toString();
mc.setPayloadXML(
<CelsiusToFahrenheit xmlns="http://www.w3schools.com/webservices/">
<Celsius>{cel}</Celsius>
</CelsiusToFahrenheit>);</script>
<property name="messageType" value="text/xml" scope="axis2"/>
<log level="full"/>
</inSequence>
<outSequence>
<log level="full"/>
<property name="messageType" value="text/xml" scope="axis2"/>
<send/>
</outSequence>
<endpoint>
<address uri="http://www.w3schools.com/webservices/tempconvert.asmx"
format="soap11"/>
</endpoint>
</target>
<description/>
</proxy>
But i am getting the exception like this
`[2014-03-20 18:19:02,391] INFO - LogMediator To: /services/JsonToXMLProxy.JsonToXMLProxyHttpEndpoint, MessageID: urn:uuid:a2eeeb26-94e1-4ed1-a3f9-79f1d1461821, Direction: request, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><CelsiusToFahrenheit xmlns="http://www.w3schools.com/webservices/"><Celsius>20</Celsius></CelsiusToFahrenheit></soapenv:Body></soapenv:Envelope>
[2014-03-20 18:19:03,130] WARN - ClientHandler Received an unexpected response - of content type : text/html and status code : 411 with reason : Length Required For : 172.26.40.214:8080 For Request : Axis2Request [Message ID : urn:uuid:39d47344-f74c-4ec5-855b-5eb90e178b6d] [Status Completed : true] [Status SendingCompleted : true]
[2014-03-20 18:19:04,133] INFO - BuilderUtil OMException in getSOAPBuilder
org.apache.axiom.om.OMException: SOAP message MUST NOT contain a Document Type Declaration(DTD)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createDTD(StAXSOAPModelBuilder.java:462)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:282)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:140)
at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:659)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:198)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:146)
at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:253)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
[2014-03-20 18:19:04,137] INFO - BuilderUtil Remaining input stream :[]
[2014-03-20 18:19:04,137] WARN - ClientWorker Unexpected response received. HTTP response code : 411 HTTP status : Length Required exception : SOAP message MUST NOT contain a Document Type Declaration(DTD)
[2014-03-20 18:19:04,153] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:39d47344-f74c-4ec5-855b-5eb90e178b6d, Direction: response, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>411</faultcode><faultstring>Unexpected response received. HTTP response code : 411 HTTP status : Length Required exception : SOAP message MUST NOT contain a Document Type Declaration(DTD)</faultstring><detail>Unexpected response received. HTTP response code : 411 HTTP status : Length Required exception : SOAP message MUST NOT contain a Document Type Declaration(DTD)</detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>`
Please help me for this issue
Thanks in advance.
you could use this example using de payloadfactory mediator to build the messages, it work for me in your scenario:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JsonToXMLProxy"
transports="https http local"
startOnLoad="true"
trace="disable">
<description/>
<target>
<endpoint>
<address uri="http://www.w3schools.com/webservices/tempconvert.asmx" format="soap11"/>
</endpoint>
<inSequence>
<log>
<property name="TEMPERATURA_ENTRADA" expression="json-eval($.celsius)"/>
</log>
<payloadFactory media-type="xml">
<format>
<web:CelsiusToFahrenheit xmlns:web="http://www.w3schools.com/webservices/">
<web:Celsius>$1</web:Celsius>
</web:CelsiusToFahrenheit>
</format>
<args>
<arg evaluator="json" expression="$.celsius"/>
</args>
</payloadFactory>
<header name="Action"
value="http://www.w3schools.com/webservices/CelsiusToFahrenheit"/>
</inSequence>
<outSequence>
<log>
<property xmlns:p="http://www.w3schools.com/webservices/"
name="TEMPERATURA_SALIDA"
expression="//p:CelsiusToFahrenheitResponse/p:CelsiusToFahrenheitResult"/>
</log>
<payloadFactory media-type="json">
<format>
"Temperatura" : {
"EnFahrenheit" : $1
}
</format>
<args>
<arg xmlns:p="http://www.w3schools.com/webservices/"
evaluator="xml"
expression="//p:CelsiusToFahrenheitResponse/p:CelsiusToFahrenheitResult"/>
</args>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<send/>
</outSequence>
</target>
</proxy>