log wso2 esb request/responses to database - wso2

I want to build a logger that logs all incoming requests and their response to a database. For this I created an axis2 module that should do this in the Inflow and the Outflow - I do not want to trigger the logging from the sequences, because then I would need to put the logger in all my services.
My problem is: how can I relate the incoming message in ESB to the return message? I think this is where Synapse comes in, but I cannot find the right properties to link the messages together: there is no messageId or correlationid that I can use to do this.
Is there a way to access the Synapse properties of the message in the axis2 handler?

Axis2 module is a right option. To identify request and responses, you can check the messageIDs. And if you want to access request messagecontext in the relavant responsemessage context try following code block;
MessageContext requestMessageCtx = responseMessageCtx.getOperationContext()
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
Here is a blog post

Related

Apache CXF headers needed inside soap web service

We are having a apache cxf web service. I wrote an inInterceptor which logs the headers to the console.
Our web service has layers like service,serviceImpl......dao
Whre we struck is, we want one of the headers (which is unique for each request) available at DAO.
Is there a way I can achieve this?
You can retrieve the current CXF Message using PhaseInterceptorChain.getCurrentMessage(). Once you have the message, you can retrieve the headers just like you would in an Interceptor. For example:
Message message = PhaseInterceptorChain.getCurrentMessage();
Map<String, List<String>> headers = (Map<String, List<String>>) message
.get(Message.PROTOCOL_HEADERS);

Error message in wso2 dss

I'm using wso2 esb4.7.0 and wso2 dss 3.1.0.I have created a dataservice in dss and tested using try this service tool.It's working fine but when same dataservice is being fetch in esb using it's adress endpoint it showing following error -
ERROR {org.wso2.carbon.statistics.internal.ResponseTimeCalculator} - wso2statistics.request.received.time is null in the IN MessageContext
why so?is their any problem with esb?or it's internal problem?please let me know..
You have to set message headers using Header mediator. At least you have to set "To" and "Action" headers before you send payload to the data service. To get the write value of To and Action headers you can use Soap Tracer tool in monitor tab of WSO2-DSS management console. Run the tool, try the data service and refresh the tool to see the results of your trying. In the left side of the page of Soap Tracer tool you will see the To and Action, copy values from there and put them in header mediators you are using.

WSO2 API Manager: How do I log the fulle (http) SOAP response

How do I log the SOAP response messages (complete http response) when I invoke a service on the WSO2 AM?
If you want to see all the messages that are passing through, you can enable the wire level logs. It will log all http messages. Please uncomment following two properties in "log4j.properties" file which can be found at /repository/conf directory
uncomment the following logs to see HTTP headers and messages
log4j.logger.org.apache.synapse.transport.http.headers=DEBUG
log4j.logger.org.apache.synapse.transport.http.wire=DEBUG
You can use log mediator to log the response. Add log mediator with level="full" at your out sequence of the API(repository\deployment\server\synapse-configs\default\api) configuration. After editing the sequence, restart the server.
OR else, you can define your custom sequence to log message and you can add that when you try to publish the API.

Custom Uri or endpoint on WSO2

We have just installed our WSO2 ESB, and we are trying to create some proxies services with customs endpoints.
The default endoint format is:
http://{host}:{port}/services/{Proxy Service Name}
I'd like to have something like:
http://{host}:{port}/services/utilities/{Proxy Service Name}
http://{host}:{port}/services/public/{Proxy Service Name}
I followed this tutorial:
http://wso2.org/library/knowledge-base/2011/01/custom-urls-wso2-esb-proxy-services
but we have a problem, when I send a request to my custom endpoint, I have no answer.
suggestions?
I assume that you were able to properly create a custom endpoint and "I have no answer" means you didn't get any response. If it is the case following are the possible reasons for that,
Proxy service endpoint didn't receive the request
Proxy service didn't configured properly to response back
So test whether the 1 is the reason you can simply put a log mediator with following configuration in inSequence,
<log level="full"/>
then if the proxy service received a message it will log it in console. If that works could you please post your proxy service configuration to check whether it is properly defined.
Well, it seems that we've found a solution, I'm going to resume the full solution.
As the tutorial indicates, to costumize your proxy service endpoint, you have to add the following handler on the axis2.xml configuration:
<handler name="CustomURIBasedDispatcher" class="org.apache.synapse.core.axis2.CustomURIBasedDispatcher"/>
Then, you can customize your endpoint on the design view or on the source view, I've choosen the source view, adding this parameter:
<parameter name="ServiceURI">/services/intern</parameter>
The custom endpoint is autogenerated as:
http://{host}:{port}/services/intern.myWebservice
But I has not worked for me. If I send a request to the custom endpoint, I have no response.
I've solved the problem, adding to the "ServiceURI" parameter the name of the service:
<parameter name="ServiceURI">/services/intern/myWebService</parameter>
then you have to send the request to the following endpoint:
http://{host}:{port}/services/intern/myWebService
So now you have a custom endpoint for every proxy service.
Thanks Malith for your help.

wso2 carbon - how to log the soap messages to the console with log4j

I would like to dump the soap requests and responses to the console.
I have tried setting up log4:
log4j.logger.httpclient.wire=DEBUG, CARBON_CONSOLE
log4j.logger.org.apache.commons.httpclient=DEBUG, CARBON_CONSOLE
However, this isn't logging any soap requests/responses.
I don't think you can do this with Log4J properties. I enabled TRACE for like following,
log4j.logger.org.apache.axis2.builder=TRACE
log4j.logger.org.apache.axis2.transport.http.ApplicationXMLFormatter=TRACE
log4j.logger.org.apache.axis2.transport.http.SOAPMessageFormatter=TRACE
Still you can't get the SOAP messages going in and out. If you're playing around with ESB then of course you can use the Log mediator in inSequence and outSequence to get the SOAP request/response
Easiest way would be to use a tool like TCPMon (shipped with all the WSO2 products and can be found in the bin folder) or SOAP UI.
Changing the logging in wso2 might help.
Go to Configure->Logging, and set the org.apache.axis2.transport.local.LocalTransportReceiver, org.apache.axis2.transport.local.LocalTransportSender, org.apache.axis2.transport.local.LocalResponder to the DEBUG level.
It will end up in the in the repository/logs/wso2carbon.log