WSO2 ESB Tutorial Error - wso2

I found the exact same problem here but there was no answer, and I can't move on with this without an answer.
WSO2 Start - up (Sending Simple Message)
The sample I'm trying to use is hosted in WSO2 App Cloud at http://wso2training-restsamples.wso2apps.com, and the tutorial is this one: https://docs.wso2.com/display/ESB500/Sending+a+Simple+Message
As far as I know I followed the tutorial to the letter, but when I get to sending the GET request, although it logs in the Eclipse console, on my console, after doing this command:
curl -v http://localhost:8280/healthcare/querydoctor/surgery
I get this
Exception occurred :Illegal character in path at index 12: /healthcare/{uri.var.category}* Connection #0 to host localhost left intact
HealthCareAPI.xml:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/healthcare" name="HealthcareAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/querydoctor/{category}">
<inSequence>
<log description="Request Log" level="custom">
<property name="message" value=""Welcome to HealthcareService""/>
</log>
<send>
<endpoint key="QueryDoctorEP"/>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
QueryDoctorEP.xml:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="QueryDoctorEP" xmlns="http://ws.apache.org/ns/synapse">
<http method="get" uri-template="http://wso2training-restsamples.wso2apps.com/healthcare/{uri.var.category} "/>
</endpoint>

You have a typo (an extra space at the end) in your endpoint url-template. Be careful not to include whitespaces in the beggining or end of your templates.
uri-template="http://wso2training-restsamples.wso2apps.com/healthcare/{uri.var.category}"
Remove it and ou should get the expected output.

Related

WSO2 ESB reliable messaging

I have tried this sample "https://docs.wso2.com/display/ESB470/Sample+102%3A+Reliable+Message+Exchange+with+Back-End+Server+Using+WS-ReliableMessaging+1.1", and unfortunaly I couldn't understand the config explained in this sample. the config is:
<definitions xmlns="http://ws.apache.org/ns/synapse">
<in>
<RMSequence single="true" version="1.1"/>
<send>
<endpoint name="reliable">
<address uri="http://localhost:9000/services/ReliableStockQuoteService">
<enableRM/>
<enableAddressing/>
</address>
</endpoint>
</send>
</in>
<out>
<header name="wsrm:SequenceAcknowledgement" action="remove"
xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
<header name="wsrm:Sequence" action="remove"
xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
<header name="wsrm:AckRequested" action="remove"
xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
<send/>
</out>
There is no place that explain where to use this config. What is the definitions tag? What are in and out tags?
I have tried this proxy service to invoke a reliabl-messaging enabled backend.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="reliableClient"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<RMSequence single="true" version="1.0"/>
<send>
<endpoint>
<wsdl service="reliableBackEnd"
port="reliableBackEndHttpSoap11Endpoint"
uri="http://localhost:9763/services/reliableBackEnd?wsdl">
<enableAddressing/>
<enableRM/>
</wsdl>
</endpoint>
</send>
</inSequence>
<outSequence>
<header xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"
name="wsrm:SequenceAcknowledgement"
action="remove"/>
<header xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"
name="wsrm:Sequence"
action="remove"/>
<header xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"
name="wsrm:AckRequested"
action="remove"/>
<send/>
</outSequence>
</target>
<description/>
</proxy>
but it is getting time out. the backed is hosting in the same ESB 4.8.1, with default RM-Policy enabled.
#Reza,
definitions tag is the root tag of the ESB synapse config. Under the definitions tag, all the synapse artifact related configs such as proxy services, sequences, and etc are included.
Also regarding the sample you are referring,you are referring to an older version of 4.7.0 and make sure you have enabled nhttp transport. Instead of using the older version, I would like to suggest you use a newer version. Please refer [1], a nice article written by Buddhima.
[a] https://buddhimawijeweera.wordpress.com/2015/09/05/reliable-messaging-with-wso2-esb/

WSO2 ESB Proxy Basic Service Chaining

this is what I thought would be a fairly straight-forward service chaining scenario.
All I want to do it forward some data to a proxy service, that proxy service will then iterate over the data and use an ID ("entity_id") from that data (which it can successfully retrieve) to look up a resource sitting in WSO2 Data Services Server. Once it has the result of that request, I want to forward it to another application (RequestBin, in this case).
Please take a look at my proxy configuration below:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="pollService"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<iterate id="iter1"
expression="//*[local-name()='Change']"
sequential="true">
<target sequence="anon">
<sequence>
<log level="full"/>
<property name="uri.var.entityid" expression="//*[local-name()='entity_id']"/>
<call>
<endpoint>
<http method="get"
uri-template="http://54.66.155.36:9764/services/civicrm/activity/{uri.var.entityid}"/>
</endpoint>
</call>
<log level="full"/>
<call>
<endpoint>
<http method="post" uri-template="http://requestb.in/1c79v711"/>
</endpoint>
</call>
<log level="full"/>
</sequence>
</target>
</iterate>
</inSequence>
</target>
<description/>
</proxy>
I currently do not get any indication that those two calls have fired at all.
Any assistance would be greatly appreciated.
Thank you.
you can enable the wirelog and verify whether calls have fired or not.
please refer the following blog post to learn about wirelog.
1 http://mytecheye.blogspot.in/2013/09/wso2-esb-all-about-wire-logs.html
Could you also give a sample message (what is going into the proxy) , and to see a finer-grain detail of what is going on in your proxy , go into [esb-home]/repository/conf/ and open the log4j.properties file , and set
log4j.category.org.apache.synapse=DEBUG , also do as #robin suggested. Try putting
<log level="full" category="DEBUG" separator="-----:-----"/>
in your proxy where you want to see the state of the message at that point.

WS02: Invoking external weather SOAP webservice from ESB

I am trying to use WSO2 ESB (version 4.8.1) to invoke externally hosted SOAP web services. To try it out I was using a public web service for weather information (http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL), more specifically the GetWeatherInformation operation.
I have successfully consumed the web service using the soapUI tool.
I am a newcomer to SOAP and ESB, so I tried to follow a number of blog entries, but I keep on getting errors. I tried using proxy service, payload factory and send but still didn't manage. Can somebody please help me with setting this up?
Thanks
Here come a sample API to invoke GetWeatherInformation :
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
name="testws3api"
context="/testws3api">
<resource methods="GET" url-mapping="/GetWeatherInformation">
<inSequence>
<payloadFactory media-type="xml">
<format>
<GetWeatherInformation xmlns="http://ws.cdyne.com/WeatherWS/"/>
</format>
<args/>
</payloadFactory>
<send>
<endpoint>
<address uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx" format="soap11"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
You just have to send a GET http request to http://esb.hostname:8280/testws3api/GetWeatherInformation (use SoapUI or type this address in your internet browser) and you will get back the XML response from the Weather WS
It works with this proxy conf deployed in WSO2 ESB v4.8.1 :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testws3"
transports="https http"
startOnLoad="true"
trace="disable">
<target>
<endpoint>
<wsdl service="Weather"
port="WeatherSoap12"
uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/>
</endpoint>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/>
</proxy>

WSO2 ESB - WSAddressing Set To Header

I am trying to get WSO2 to work with WCF - WCF expects the WSAddressing headers to be set and correct. I am trying to use a Header Mediator with my WSDL Proxy Service and to set the To Header but it never seems to do anything - I always get the error message from WCF: "The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree."
Here is my proxy setup - what do I need to do to get this working?
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="PingService"
transports="http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<header xmlns:a="http://www.w3.org/2005/08/addressing"
name="a:To"
scope="default"
value="http://localhost/PingService/PingService.svc"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<endpoint>
<wsdl service="PingService"
port="AccountService_WsHttp"
uri="http://uk-dev-10706.wintech.local/PingService/PingService.svc?singleWsdl"/>
</endpoint>
</target>
<description/>
</proxy>
I think you can enable "WS-Addressing" for your endpoint.
http://docs.wso2.org/display/ESB480/WSDL+Endpoint
Please try with transport scope may be that will work in your case.
<header xmlns:a="http://www.w3.org/2005/08/addressing"
name="a:To"
scope="transport"
value="http://localhost/PingService/PingService.svc"/>

How to call webservice in WSO2 proxy

how I can call web service inside of proxy? Proxy itself works fine, and I added call of logging web service in "in" sequence. I create call using payload factory + send.
Problem is, that proxy now returns result of this logging web service instead of
what web service should return. There is address end point defined in "out" sequence.
I am using WSO2 ESB 4.6.0.
This is the simple example of calling web service inside of the proxy. You need to up back-end service before create the proxy
<proxy xmlns="http://ws.apache.org/ns/synapse" name="customPro" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</inSequence>
<out-sequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/>
<description></description>
</proxy>
You need to define web service url within the end-point in tag
As well as, this kind of send mediator return end-point response to outSequence
by default.
You can get good understanding of these if you go through the ESB documentation from following url
http://docs.wso2.org/display/ESB460/Samples
If you need further help, feel free to ask here
There are two ways you can achieve the logs
1. Log ESB incoming and outgoing messages through wire log.
To enable debug mode for wire logs;
- ESB console > Configure > Logging
- Set “org.apache.synapse.transport.http.wire” level to “DEBUG”.
In the log, it indicates >> incoming messages to ESB
<< outgoing messages from ESB
2. Use Logs at the appropriate place
<?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>
<log level="full">
<property name="test" value="incomming to ESB-----------------------"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
<log level="full">
<property name="test" value="outcomming from ESB-----------------------"/>
</log>
</inSequence>
<outSequence>
<log level="full">
<property name="test" value="incomming to ESB-----------------------"/>
</log>
<send/>
<log level="full">
<property name="test" value="outcomming from ESB-----------------------"/>
</log>
</outSequence>
</target>
<publishWSDL uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/>
<description/>
</proxy>
If it is resolve your problem, please flag as answered.