I am using WSO2 ESB to send a POST request to a Rest API of mine.
actually, the API returns a 201 status with some data.
The API itself using POSTMAN works perfectly, but a 202 accepted response is return using the ESB link
here's my implementation:
the POST API Link:
http://mysite/sites/4/floors/4/pois/12/prelock
My ESB API :
<resource methods="POST" uri-template="/sites/{siteId}/floors/{floorId}/pois/{poiId}/prelock">
<inSequence>
<log level="full"/>
<header name="Content-Type" scope="transport" value="application/json"/>
<property expression="$axis2:HTTP_SC" name="Status" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<send>
<endpoint key="NodeRedPrelock"/>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
<faultSequence/>
</resource>
endpoint :
<endpoint name="NodeRedPrelock" xmlns="http://ws.apache.org/ns/synapse">
<http method="post" uri-template="http://mysite/sites/{uri.var.siteId}/floors/{uri.var.floorId}/pois/{uri.var.poiId}/prelock"/>
The problem seems to be with the http method .Can you try with this
<endpoint name="NodeRedPrelock" xmlns="http://ws.apache.org/ns/synapse">
<http trace="disable" uri-template="http://169.46.25.33:1880/sites/{uri.var.siteId}/floors/{uri.var.floorId}/pois/{uri.var.poiId}/prelock"/>
</endpoint>
Are you check your sequence in Carbon interface?
Some times when you deploy car to esb carbon remove endpoint from "send" tag.
Or it's seems as problem in endpoint. You can try resave endpoint in interface. Sometimes I have problem after deploy car file and endpoint don't work until make save by hand.
Related
I followed the link ESB as a JMS Producer to configure the sender and receiver. I have also placed the following jars activemq-broker-5.8.0.jar activemq-client-5.8.0.jar activemq-kahadb-store-5.8.0.jar
geronimo-jms_1.1_spec-1.1.1.jar geronimo-j2ee-management_1.1_spec-1.0.1.jar geronimo-jta_1.0.1B_spec-1.0.1.jar hawtbuf-1.9.jar Slf4j-api-1.6.6.jar activeio-core-3.1.4.jar into WSO2_EI_HOME/lib
When I configured a proxy with the following code and tried to send the messages to the queue, but the messages aren't delivering.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Sender"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint>
<address uri="jms:/VALLYSOFTQ?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
The same configuration worked earlier for me but I don't know what happened, the messages are not going to the queue now.
Thanks in advance.
I'm trying to expose an internal REST implementation via wso2.
here's the API definition
<api xmlns="http://ws.apache.org/ns/synapse" name="API" context="/api" hostname="http://toto.com" port="80">
<resource methods="POST GET" uri-template="/{methodName}">
<inSequence trace="disable">
<send>
<endpoint>
<http uri-template="http://toto.com/1.0.1/api/{uri.var.methodName}" method="GET|POST|PUSH|PUT|DELETE"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
I'm only tying to relay the methodName.
I'm pretty new to wso2, still I can't find what's wrong here ?
Thanks for any help or links.
Well I had to remove port and hostname from the api definition in order to make it work.
Not sure why but if it can help
How do I get inbound the SOAP payload converted to a HTTP Post payload so that it can be sent via my HTTPEndpoint
An example would be greatly appreciated
You can set the endpoint format to pox to create a plain xml message to be posted. See for example: http://charithaka.blogspot.nl/2010/07/message-format-transformations-with.html
Are you referring to SOAP to REST conversion? In that case it would be like following.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="testProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="messageType" value="application/xml" scope="axis2"/>
<send>
<endpoint>
<http method="POST" uri-template="http://localhost:9000"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
The axis2 messageType property decides the MessageFormatter used to format the message before sending out. In this case its application/xml so the Content-Type of the outgoing POST request will be application/xml.
i have a custom proxy in WSO2 ESB 4.7 works correct.
But, when i copy to ESB 4.8.1 it's fail.
This is te code.
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse"
name="ExpertWS"
transports="http"
statistics="disable"
trace="enable"
startOnLoad="true"> <target>
<inSequence>
<log level="full"/>
<send>
<endpoint>
<http uri-template="http://1.33.33.103:8080/erpws/logistica/master/ume/{pEmpresa}"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence> </target> <description/> </proxy>
Any idea??
Thanks
In a http endpoint, properties names must start with "uri.var" : uri.var.pEmpresa and a value must be set
see https://docs.wso2.org/display/ESB481/HTTP+Endpoint
I am calling the rest service as sown in below
<resource methods="GET" url-mapping="/getallpayments" faultSequence="error_handler_">
<inSequence>
<log level="custom">
<property name="CashreceiptsService" value="**************Entered into getallpayments*************"/>
<property name="Request Payload" expression="get-property('JSON_OBJECT')"/>
</log>
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
<property name="messageType" value="application/json" scope="axis2"/>
<oauthService remoteServiceUrl="https://localhost:9443/services/OAuth2TokenValidationService/" username="admin" password="admin"/>
<log level="custom">
<property name="CashreceiptService" value="^^^^^^^^^^^^OAUTH COMPLETED^^^^^^^^^^^^"/>
<property name="User Name******" expression="get-property('username')"/>
</log>
<send>
<endpoint>
<http format="rest" method="GET" uri-template="http://localhost:8080/rest/commonService/getallpayments"/>
</endpoint>
</send>
<drop/>
</inSequence>
It will gives the below response
[{"typeId":1,"name":"Entity_Type","value":"EMPLOYER","description":"Employer","createdDate":"08/12/2013","tenantId":0,"hasPhiFields":false},{"typeId":2,"name":"Entity_Type","value":"BROKER","description":"Broker","createdDate":"08/12/2013","tenantId":0,"hasPhiFields":false}]
I am able to get the above response in the UI.
But i need the response of "typeId" inside the Api and that typeId i need to get and pass to the another service as a input parameter and this service will give the final response to the UI.
Right now i am implementing using the service chaining.
Main issue is how to get the response of one service and pass to another service as input param? please suggest me, i am new to WSO2 ESB.
And also how to get the POST data send by user?
you may grab the values in out sequence else any other sequence for getting response from their you may send to another endpoint or proxy or any endpoint
in your case you get the values in out sequence or any other sequence u need adopt particuler object like this
<property xmlns:f="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd" name="typeid" expression="//f:typeid/text" scope="default" type="STRING"/>
or else u define as per your endpoint
<send receive="someothersequencename">
<endpoint>
<http format="rest" method="GET" uri-template="http://localhost:8080/rest/commonService/getallpayments"/>
</endpoint>
</send>
then u will get all response in this sequence