WSO2 ESB - WSAddressing Set To Header - wso2

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"/>

Related

Transport error: 404 Error: Not Found in wso2 esb

i use from wso2 esb to add proxy service. i hvae an error when i try to call this web service. this is my proxy service :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="citynetserviceMain"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="DISABLE_CHUNKING"
value="true"
scope="axis2"
type="STRING"/>
<send>
<endpoint>
<address uri="http://citynetservice..../CityBank.svc?wsdl"
format="soap12"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="http://citynetservice..../CityBank.svc?wsdl"/>
<description/>
</proxy>
when i try to call this proxy service it throw an exception :
<TryitProxyError xmlns:h="http://wso2.org/ns/TryitProxy" h:status="SOAP envelope error">org.apache.axis2.AxisFault: Transport error: 404 Error: Not Found</TryitProxyError>
Not sure if you are facing the same issue as mine, but I've had the same problem when an other server (tomcat) was listening on port 8280.
The ESB start without any problem but you can find an error in esb logs that say that port is already in use
You can access ESB console on port 9443 and use "try this service", but in my case, tomcat were sending back a 404.
Hope it can help.

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>

retrieve corelationId of JMS message in wso2 esb

I have created a queue in activeMQ and also created a proxy service which is listening for messages on that queue.
While testing, I have put up a sample message to ActiveMQ queue using the console provided by ActiveMQ and set its corelationId but I am unable to retrieve the same corelation ID in the proxy service.
Below is the proxy code to retrieve the same.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JMSQueueConsumer"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="custom">
<property name="corelationId" expression="get-property('JMS_COORELATION_ID')"/>
</log>
<property name="OUT_ONLY" value="true" scope="default" type="BOOLEAN"/>
</inSequence>
</target>
<parameter name="transport.jms.Destination">WSO2InQueue</parameter>
<description/>
</proxy>
In the logs I am getting the value of "corelationId" as null.
Can anybody help me on this?
you will find this corelationId in the transport scope :
get-property('transport','JMS_COORELATION_ID')

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.

Service Mediation Using Proxy Services -WSO2

I'm new to this area and i need to access my web service via the ESB. as it mentioned in here - Service Mediation Using Proxy Services i tried to to create it. after that i run it and get the response as follows :
<TryitProxyError xmlns:h="http://wso2.org/ns/TryitProxy"
h:status="SOAP envelope error">org.apache.axis2.AxisFault:
The input stream for an incoming message is null.</TryitProxyError>
but i tried to run same web method using SOAPUi and get the expected out put as below:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<getPatientHistoryResponse xmlns="http://tilani.lk/">
<getPatientHistoryResult>
<NIC>123</NIC>
<FullName>ABC DEF</FullName>
<FirstName>ABC</FirstName>
<Surname>DEF</Surname>
<Title>Mr.</Title>
<Gender>M/Gender>
</getPatientHistoryResult>
</getPatientHistoryResponse>
</soap:Body>
</soap:Envelope>
what is the reason for this? i created this using .net
my WSDL Address - http://localhost:2935/PatientRegService.asmx?WSDL
then in
Define Endpoint as - http://localhost:2935/PatientRegService.asmx
EDIT
my proxy configuration is as follows:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="PatientManagement" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<address uri="http://localhost:2935/PatientRegService.asmx?WSDL"/>
</endpoint>
</target>
<publishWSDL uri="http://localhost:2935/PatientRegService.asmx?WSDL"/>
<description></description>
</proxy>
If you just want to access your web service via ESB you need to create a proxy service and access the proxy service URI instead of the original service URI. Just follow the Pass Through Proxy example.
Try the following proxy and see waht you are getting. Add this proxy configuration via source view editor.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testProxy"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<log level="full">
<property name="testprop" value="incoming message"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:2935/PatientRegService.asmx"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>