I have a proxy service with below definition:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<header name="Action" value="urn:loadPerson"/>
<payloadFactory media-type="xml">
<format>
<sear:loadPerson xmlns:sear="http://localhost/SearchService">
<sear:Id>1234</sear:Id>
</sear:loadPerson>
</format>
<args/>
</payloadFactory>
<log level="full"/>
<call>
<endpoint key="SearchService"/>
</call>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
So it's work fine when I call the proxy service(by tryIt) first time and I get right response of proxy service but for the next time it faces a problem and show me fault response:
<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>axis2ns11:Server</faultcode>
<faultstring>Missing operation for soapAction [urn:loadPerson] and body element [null] with SOAP Version [SOAP 1.1]</faultstring>
</soapenv:Fault>
As you can see I log the message and it's the same for every proxy call:
INFO - LogMediator To: /services/TestProxy.TestProxyHttpSoap11Endpoint, WSAction: urn:loadPerson, SOAPAction: urn:loadPerson, MessageID: urn:uuid:cc9557cc-e2a0-4b8d-97a8-ae393a411157, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><sear:loadPerson xmlns:sear="http://localhost/SearchService"><sear:Id>1234</sear:Id></sear:loadPerson></soapenv:Body></soapenv:Envelope>
I found that the problem resolved by restarting the server(not redeploying the proxy service) or leave it for few minutes!
any idea?!
Related
I'm defining an API in wso2esb for one of the tenants. This tenant automatically gets it's own context path when defining an API (e.g. http://127.0.0.1:8280/tenant1/api-identifier/).
The next step is that this request gets forwarded to an http endpoint (e.g. http://127.0.0.1:9191/v1/). But when looking at the logs the esb tries to send this request to http://127.0.0.1:9191/v1/tenant1/api-identifier/ which can't give a response. Can I remove this part from the url. It feels like this should work out of the box.
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<registry provider="org.wso2.carbon.mediation.registry.WSO2Registry">
<parameter name="cachableDuration">1500</parameter>
</registry>
<taskManager provider="org.wso2.carbon.mediation.ntask.NTaskTaskManager"/>
<sequence name="In">
<log category="TRACE" level="full"/>
<send>
<endpoint key="gov:/HelloWorld"/>
</send>
</sequence>
<sequence name="fault">
<log level="full"/>
</sequence>
<sequence name="main">
<in>
<log/>
<sequence key="conf:/InSecure"/>
</in>
<out>
<send/>
</out>
</sequence>
<sequence name="Out">
<send/>
</sequence>
<sequence name="InSecure">
<log/>
<send>
<endpoint key="gov:/HelloWorld"/>
</send>
</sequence>
<api context="/lensworld.be/hw" hostname="192.168.1.100"
name="HelloWorld" port="9191">
<resource inSequence="InSecure" methods="GET" outSequence="Out"/>
</api>
Try removing the REST_URL_POSTFIX property:
<property name="REST_URL_POSTFIX" action="remove" scope="axis2"/>
From the docs:
The value of this property will be appended to the target URL when sending messages out in a RESTful manner through an address endpoint. This is useful when you need to append a context to the target URL in case of RESTful invocations. If you are using an HTTP endpoint instead of an address endpoint, specify variables in the format of "uri.var.*" instead of using this property.
I am working on Cache Mediator in wso2esb. My requirement is to get Hash Digest value generated by org.wso2.carbon.mediator.cache.digest.DOMHASHGenerator class in this mediator.
<sequence name="In_Seq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<cache collector="false"
hashGenerator="org.wso2.carbon.mediator.cache.digest.DOMHASHGenerator"
id="MyCache" maxMessageSize="2000" scope="per-host" timeout="120">
<onCacheHit/>
<implementation maxSize="1000" type="memory"/>
</cache></sequence>
<sequence name="Out_Seq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<cache collector="true" id="MyCache" scope="per-host"/>
</sequence>
Can you tell me how to do that?
Very simple example. Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<T>
<m1>bysy</m1>
<m1>momo</m1>
<m1>gigi</m1>
</T>
</soapenv:Body>
</soapenv:Envelope>
I want to iterate and log every element in tag m1.
Proxy code:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Loopback" transports="https,http"
<target>
<inSequence>
<property name="OUT_ONLY" value="true" scope="axis2"/>
<iterate expression="//T/m1">
<target>
<sequence>
<property name="OUT_ONLY" value="true" scope="axis2"/>
<log level="custom">
<property name="M1" expression="//text()"/>
</log>
<drop/>
</sequence>
</target>
</iterate>
</inSequence>
</target>
</proxy>
It work as expected and logs all values. But WSO2ESB server doesn't close connection, until it falls with timeout. (I use SOAPUI for testing)
I tried to put properties OUT_ONLY RESPOND NO_KEEPALIVE in different part of proxy but it didn't help, as well I tried to use , with same result.
It looks like problem in iterate mediator which doesn't let to inSequence to terminate and send response to client. Once i remove it, proxy disconnect immediately with status code '202' message accepted.
This is because, by default, attribute "continueParent" is set to false with iterate mediator : change to <iterate continueParent="true" expression="//T/m1">
And you should explicitly send a 202 inside your inSequence, set this property : <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
I am experimenting with WSO2 ESB to secure by REST APIs, by following this approach: https://docs.wso2.com/display/ESB480/Securing+REST+APIs
My API configuration:
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
name="Test"
context="/test">
<resource methods="GET">
<inSequence>
<log level="full">
<property name="STATUS" value="***** REQUEST HITS IN SEQUENCE *****"/>
</log>
<send>
<endpoint>
<http method="get" uri-template="http://localhost:8080/document"/>
</endpoint>
</send>
</inSequence>
</resource>
<handlers>
<handler class="org.wso2.handler.SimpleOauthHandler"/>
</handlers>
</api>
When I remove the handler section, I can see my service being invoked. But when I include the ouath handler, I can see my WSO2 Identity Server receiving the token validation call but the response from ESB is always HTTP 202.
curl -v -X GET -H "Authorization: Bearer UQFffmYViFDxTHfCLOwDpjcX3qXZYQuiJ8EgJ_m-F1V7JTgqb6lbyA8QMT3" http://localhost:8285/document
> GET /document HTTP/1.1
> User-Agent: curl/7.33.0
> Host: 192.168.2.162:8285
> Accept: */*
> Authorization: Bearer UQFffmYViFDxTHfCLOwDpjcX3qXZYQuiJ8EgJ_m-F1V7JTgqb6lbyA8QMT3
>
< HTTP/1.1 202 Accepted
< Date: Fri, 10 Apr 2015 20:44:57 GMT
* Server WSO2-PassThrough-HTTP is not blacklisted
< Server: WSO2-PassThrough-HTTP
< Transfer-Encoding: chunked
Any pointers on what am I missing or how I can debug would be appreciated.
Thank you.
It was in fact issue with my access token. Using the right token worked right. Also OAuth mediator can be used instead of handler.
<api xmlns="http://ws.apache.org/ns/synapse"
name="Test"
context="/test">
<resource methods="GET">
<inSequence>
<log level="full">
<property name="STATUS" value="***** REQUEST HITS IN SEQUENCE *****"/>
</log>
<oauthService remoteServiceUrl="https://localhost:9445/services/" username="admin" password="admin"/>
<send>
<endpoint>
<http method="get" uri-template="http://localhost:8080/document"/>
</endpoint>
</send>
</inSequence>
</resource>
</api>
I have exposed a REST service using <api> in wso2 esb. But the response does not come. REST service is written in Apache Wink.
API
<api name="API_2" context="/hello" hostname="localhost" port="8080">
<resource url-mapping="/name" methods="GET">
<inSequence>
<log level="full"/>
<property name="messageType" value="text/plain" scope="transport" type="STRING"/>
<send>
<endpoint>
<address uri="http://localhost:8080/HelloService/rest/test/hello"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
</resource>
</api>
esb log
[2013-12-11 12:28:24,643] INFO - API Initializing API: API_2
[2013-12-11 12:28:35,467] INFO - LogMediator To: /hello/name, MessageID: urn:uuid:52d2ddf1-301e-42e0-ac9d-ac4a57ac8c72, Direction: request
I think your endpoint address is wrong , look like you have repeat hello twice. since you have hello in proxy name also which will append to URL.
try <address uri="http://localhost:8080/HelloService/rest/test"/>
Also You can verify your backend works by calling "uri + url-mapping" in separate browser
I have shown sample API works for me below, you should have called your API as below and log will print as below.
URL to call: http://localhost:8280/TestAPI/customerservice/customers/123
INFO - LogMediator To: /TestAPI/customerservice/customers/123
<api xmlns="http://ws.apache.org/ns/synapse" name="TestAPI" context="/TestAPI">
<resource methods="GET" url-mapping="/customerservice/customers/123">
<inSequence>
<log/>
<send>
<endpoint>
<address uri="http://localhost:9764/jaxrs_basic/services/customers"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log/>
<send/>
</outSequence>
</resource>
</api>