I implemented a simple pass through proxy i.e. when i call
"http://wso2esb:9443/services/proxy"
it should forward the request to
"http://destinationserver:80/" .
The question is the url extensions are not carried while forwarding.. i.e.
when i do a HTTP POST in
http://wso2esb:9443/services/proxy/path1/path2
the request is forwarded to
http://destinationserver:80
rather than to
http://destinationserver:80/path1/path2.
but HTTP GET behaves as expected. Could anyone help in where i am going wrong?
My Proxy.xml
<proxy xmlns="http://ws.apache.org/ns/synapse" name="proxy" transports="https,http"
statistics="disable" trace="disable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<address uri="http://destinationserver:80/"/>
</endpoint>
</target>
<description/>
</proxy>
Thanks in advance!
P.S: my WSO2ESB version : 4.8.1
If you really need that, one way (not sure this is the best) to achieve your goal would be :
<proxy xmlns="http://ws.apache.org/ns/synapse" name="proxy" transports="https,http"
statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<header name="To"
expression="concat('http://destinationserver:80',substring-after(syn:get-property('To'),'/services/proxy'))"/>
<send/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
Send a post request to http://wso2esb:8280/services/proxy/path1/path2 and it should be forwarded to http://destinationserver:80/path1/path2
Things worked as per Jeans answer but Htttp HEAD request is not forwarded except it is returning 400 Bad Request. Testing with direct link on the destination server returns expected response.
Related
I have the JMS message as
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<content>
<entry type="1">
<textMessage JMSDeliveryMode="2" JMSDestination="queue:///QUEUE" JMSExpiration="0" JMSMessageID="ID:c3e2d840d8e3c1f14040404040404040cf1eba01c4eff036" JMSPriority="4" JMSRedelivered="false" JMSTimestamp="1434705226223" fromQueue="true" codec="Base64">
<text>dGVzdA==</text>
</textMessage>
</entry>
</content>
but when i pull it into wso2 esb it gets into soap envelope and i'm not able to retrieve the properties over here, like JMSDestination etc.
I want to read those details in WSO2 ESB. Is there a way?
I get the following SOAP message after getting the message from JMS, and it is logging or the xPath works only on this.
[2015-06-22 11:08:33,632] INFO - LogMediator To: , WSAction: urn:mediate, SOAPA
ction: urn:mediate, MessageID: ID:c3e2d840d8e3c1f14040404040404040cf224f7f3bbf47
25, Direction: request, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv
:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Bod
y>test1</soapenv:Body></soapenv:Envelope>
Thanks
I'm setting the JMS headers in my sending proxy like this.
In the receiving proxy, you can then access the property with get-property like in the following example.
<log level="custom">
<property name="Autodeploy_TSONL_CreateProxyTarget - Config Params transport intervall "
expression="get-property('transport','TRANSPORT_TRANSFERINTERVALL')"/>
Hope that helps.
You can select any information from the message body (even if there is a soap envelope for internal purposes) with the following code in your inSequence:
<property name="JMSDestination" expression="$body/content/entry/textMessage/#JMSDestination"/>
Verify that your message is being build with an appropriate message builder, otherwise you can't see the message content. See this JMS Proxy example:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="JMSProxyName" transports="jms" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="custom">
<property name="Log JMSDestination" expression="$body/content/entry/textMessage/#JMSDestination"/>
</log>
<drop/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.Destination">YourQueue</parameter>
</proxy>
I have a Oracle database view containing details of around 8000 employees. I need to populate employee search suggestions from that view. I'm planning to use WSO2 DSS/ DSS+ESB to create a data service for that. Rather querying the view for each and every service call, i'm thinking of caching the whole view in DSS/ESB and query the cache for all the filter queries("like", "where" queries) until cache expires.
Is there any possibilities around ESB/DSS related to the above scenario?
Thanks in advance.
You can use cache mediator with WSO2 ESB :
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Test" transports="https http" startOnLoad="true" trace="disable">
<description/>
<target>
<inSequence>
<cache id="someCache" scope="per-host" collector="false" hashGenerator="org.wso2.caching.digest.DOMHASHGenerator" timeout="10">
<onCacheHit>
<log level="custom">
<property name="debug" value="incache"/>
</log>
<header name='To' action="remove"/>
<send/> <!-- send back previous reponse, outSequence will not be executed -->
</onCacheHit>
<implementation type="memory" maxSize="1000"/>
</cache>
<send> <!-- Current request (hash) has not been found in the cache -->
<endpoint>
<address uri="http://myhost:8080/myapp/MyService"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<cache id="someCache" scope="per-host" collector="true"/> <!-- Add this response to the cache -->
<log level="custom">
<property name="debug" value="outseq"/>
</log>
<send/>
</outSequence>
</target>
</proxy>
Inside the inSequence, if current request exists in the cache, 'onCacheHit' mediation will be executed with previous response. Otherwise, the 'send' to the endpoint will be executed
Inside outSequence, you add the response to the cache
i m using the wso2ESB 4.8.0 and i followed the sample at this url:
https://docs.wso2.org/display/ESB480/Sample+62:+Routing+a+Message+to+a+Dynamic+List+of+Recipients+and+Aggregating+Responses
writing this proxy service:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="adminBroadcastEndpoint"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<send>
<endpoint>
<recipientlist>
<endpoint>
<address uri="http://127.0.0.1:8080/RestService/rest/servizio/"/>
</endpoint>
<endpoint>
<address uri="http://127.0.0.1:8081/RestService/rest/servizio/"/>
</endpoint>
</recipientlist>
</endpoint>
</send>
<drop/>
</inSequence>
<outSequence>
<payloadFactory media-type="xml">
<format>
<broadcast>
$1
</broadcast>
</format>
<args>
<arg evaluator="xml" expression="$body/root"/>
</args>
</payloadFactory>
<aggregate>
<completeCondition>
<messageCount/>
</completeCondition>
<onComplete xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" expression="/">
<send/>
</onComplete>
</aggregate>
</outSequence>
</target>
<description/>
</proxy>
in the recipient list there are two servers who answer with an xml string. The first server answer with
<root>
<codice>0</codice>
<messaggio>MESSAGE1</messaggio>
<result><name>CorreggiPecJob1</name><group>POSTA1</group></result>
<result><name>SchedulaIndiceJob1</name><group>INDICE1</group></result>
</root>
and the second server with:
<root>
<codice>0</codice>
<messaggio>MESSAGE2</messaggio>
<result><name>CorreggiPecJob2</name><group>POSTA2</group></result>
<result><name>SchedulaIndiceJob2</name><group>INDICE2</group></result>
</root>
After the aggregate mediator i should expect a result with all those 2 message merged... but in the response from the proxy service i get just the second server answer or the first one randomly.
If i put a log mediator suddenly after the onComplete tag hawever i the esb prints the whole merged message with the two response, but it seems that on the send mediator something goes lost.
Why does this happen?
Another question is: why xpath expressions like
$body/broadcast//result
don't work rising this exception?
2014-03-02 17:37:32,021] ERROR - AggregateMediator Error evaluating expression: $body/broadcast//result
org.apache.synapse.SynapseException: Could not find matching elements to aggregate.
I realize that if i define a namespace and a prfix to append in the payloadfactory like:
<payloadFactory xmlns:m0="my.namespace" media-type="xml">
<m0:format>
<m0:broadcast>
$1
</m0:broadcast>
</m0:format>
<args>
<arg evaluator="xml" expression="$body/root"/>
</args>
</payloadFactory>
the expression: $body/m0:broadcast work fine... so is it the namespace definition mandatory?
Is it there anything i'm missing? thanks
If the XML elements are in namespaces, than you're XPath must either define and use namespace prefixes, or specify any namespace in the path steps, like this:
$body/*:broadcast
i found the answer here: wso2 ESB : Split / Gather Pattern - Single Response
i solved using the enrich mediator. But i think that the aggregate mediator has not a really correct behaviour... maybe should be checked.
I am using wso2esb4.7.0 i have written jms proxy so i wish send my data to endpoint but i am unable process this
my proxy is
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="MediaMoveQueue"
transports="jms"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="readingspayload" expression="$body"/>
<payloadFactory media-type="xml">
<format>
<p:hello xmlns:p="http://jaxws.youtility.in/">
<arg0 xmlns="">$1</arg0>
</p:hello>
</format>
<args>
<arg evaluator="xml" expression="get-property('readingspayload')"/>
</args>
</payloadFactory>
<!--header name="Action" value="hello"/-->
<log level="full"/>
<send>
<endpoint>
<address uri="http://192.168.1.2:8282/services/media_move_service_i_f"
format="soap11"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
</target>
</proxy>
in this proxy i am getting the data like this if i log this esb
my log is look like this
{"timestamp":1383715637698,"tmpfilename":"313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","objecttype":"Punch","filename":"enterprisedb_order.pdf","totalfilesize":994086,"uuid":"313d79a7-c29b-4e1a-9609-818610a6a66b","objectid":"313d79a7-c29b-4e1a-9609-818610a6a66b","fullpath":"/tmp/tmpmedia//313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","deviceId":"911202500210109","filemimetype":"PNG"}
but i need to just send that json format of data to my endpoint for that i have tried this xpath but its showing errors of name space how would i get this
$axis2ns58:text
but its throwing errors i wish to send that data to my endpoint
i have tried this but i need above format of data only
//soapenv:Body
its giving like this result
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<axis2ns58:text xmlns:axis2ns58="http://ws.apache.org/commons/ns/payload">{"timestamp":1383715637698,"tmpfilename":"313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","objecttype":"Punch","filename":"enterprisedb_order.pdf","totalfilesize":994086,"uuid":"313d79a7-c29b-4e1a-9609-818610a6a66b","objectid":"313d79a7-c29b-4e1a-9609-818610a6a66b","fullpath":"/tmp/tmpmedia//313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","deviceId":"911202500210109","filemimetype":"PNG"}</axis2ns58:text>
</soapenv:Body>
but i wish to send below data to my endpoint even payload also not supporting for this
{"timestamp":1383715637698,"tmpfilename":"313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","objecttype":"Punch","filename":"enterprisedb_order.pdf","totalfilesize":994086,"uuid":"313d79a7-c29b-4e1a-9609-818610a6a66b","objectid":"313d79a7-c29b-4e1a-9609-818610a6a66b","fullpath":"/tmp/tmpmedia//313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","deviceId":"911202500210109","filemimetype":"PNG"}
You could try doing
//soapenv:Body/ns:text
and set the namespace
ns="http://ws.apache.org/commons/ns/payload"
Try this:
Modify your Proxy service as below :
Instead of <property name="readingspayload" expression="$body"/> , modify it to below,
<property xmlns:ns="http://ws.apache.org/commons/ns/payload" name="readingspayload" expression="$body/ns:text/text()"/>
****
Hope this should work!!!
I use clone to send a request to different servers, and use aggregate in outSequence. It can receive all response. Some may success, and some may response error. But I don't know which server response error. I think I need get URL for any response messages.
Anyone can help me?
My service config code is here:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CloneTest" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<clone id="12345">
<target>
<endpoint>
<address uri="http://172.21.11.21:28888/usm/services/receiveMsg" format="pox" />
</endpoint>
</target>
<target>
<endpoint>
<address uri="http://172.21.11.22:28888/usm/services/receiveMsg" format="pox" />
</endpoint>
</target>
</clone>
</inSequence>
<outSequence>
<aggregate>
<completeCondition>
<messageCount min="10" max="10"/>
</completeCondition>
<send/>
</outSequence>
</target>
</proxy>
Best regards.
You can retrieve the Remote address/ host using following properties. Use to filter based on those values.
<property name="Remote address --> " expression="get-property('axis2','REMOTE_ADDR')"/>
<property name=" Remote host ---->" expression="get-property('axis2','REMOTE_HOST')"