Tested soap with attachment Axis 2 server sample soapWithAttachment service using soap UI client; any attachments formats jpeg, png, xml can be uploaded successfully through soap UI. Below is the input soap xml used to post in Soap UI and attached the attachment to the soap UI and post it. How this can be achieved through WSO2 ESB?
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://service.soapwithattachments.sample">
<soap:Header/>
<soap:Body>
<ser:uploadFile>
<!--Optional:-->
<ser:name>new2</ser:name>
<!--Optional:-->
<ser:attchmentID>new13.xml</ser:attchmentID>
</ser:uploadFile>
</soap:Body>
</soap:Envelope>
As per my analysis client needs to process the file using data handler and generate the Attachment ID, this would be inbuilt for Soap UI; I would like to know how this can be achieved through WSO2 ESB without using custom Java mediator. I am using WSO2 version 4.9.0. I have created the WSO2 ESB proxy as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="attachmentProxy"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target faultSequence="fault">
<inSequence>
<send>
<endpoint>
<address uri="http://localhost:8080/axis2/services/soapWithAttachment"
optimize="mtom"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="http://localhost:8080/axis2/services/soapWithAttachment?wsdl"/>
</proxy>
Related
I am working on conditional router in wso2 esb and my scenario is as follows.
I extracted studentno in payload and wanted to perform conditional router on the top of that but this is working for header and query params and not for query variables or a value extracted from payload. I tried for the solution but I got switch-case as a solution. Is this is a limitation in conditional router that works only with header and params? If no please provide your inputs on the condition in conditional router.
Thanks in advance.
There are two types to achieve your requirement. You should be able to use either the type soap [2] or the type property [1] to route based on the payload content. Refer to the sample below. The other available types can be found in the documentation [3].
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="conditionalRouter"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<property expression="$body//symbol" name="requestProperty"/>
<log level="custom">
<property expression="$body//symbol" name="requestProperty"/>
</log>
<conditionalRouter continueAfter="false">
<conditionalRoute breakRoute="false">
<condition>
<match regex="WSO2.*" source="//symbol" type="soap"/>
</condition>
<target sequence="cnd1_seq"/>
</conditionalRoute>
<conditionalRoute breakRoute="false">
<condition>
<match regex="IBM.*" source="requestProperty" type="property"/>
</condition>
<target sequence="cnd2_seq"/>
</conditionalRoute>
</conditionalRouter>
</inSequence>
</target>
<description/>
</proxy>
request 1
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<request>
<symbol>WSO2</symbol>
</request>
</soapenv:Body>
</soapenv:Envelope>
request 2
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<request>
<symbol>WSO2</symbol>
</request>
</soapenv:Body>
</soapenv:Envelope>
Note
The Conditional Router Mediator is removed from the EI 6.5.0 version onwards [4]. Therefore if you have already developed your mediation using the switch case mediator, better to use the same since it would be easier for you if you decide to migrate to a new EI version.
[1]-https://github.com/wso2/wso2-synapse/blob/v2.1.7-wso2v111/modules/commons/src/main/java/org/apache/synapse/commons/evaluators/config/TextProcessingEvaluatorFactory.java#L60
[2]-https://github.com/wso2/wso2-synapse/blob/v2.1.7-wso2v111/modules/commons/src/main/java/org/apache/synapse/commons/evaluators/config/TextProcessingEvaluatorFactory.java#L66
[3]-https://docs.wso2.com/display/EI620/Sample+157%3A+Conditional+Router+for+Routing+Messages+based+on+HTTP+URL%2C+HTTP+Headers+and+Query+Parameters
[4]-https://docs.wso2.com/display/EI650/About+this+Release
I'm trying to expose SOAP backend as REST API using wso2 ESB. I'm using payload factory to send the soap body message, but it doesn't work.
This is my API resource in wso2 esb code :
<?xml version="1.0" encoding="UTF-8"?>
<api context="/akademik" name="SampleAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/students?symbol={symbol}">
<inSequence>
<log level="custom">
<property expression="$url:symbol" name="symbol"/>
</log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:sem="http://semogabisa.te.net/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sem:sayHi>
<arg0>$1</arg0>
</sem:sayHi>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$url:symbol"/>
</args>
</payloadFactory>
<header scope="default">
<m:complexHeader xmlns:m="http://org.synapse.example">
<m:property key="Content-Type" value="application/xml"/>
</m:complexHeader>
</header>
<send>
<endpoint>
<address format="soap11" uri="http://localhost:8084/HelloWorld"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
Soap messages are not sent to the backend web service, it says null.
I've test the backend service with SOAPUI with same soap envelope format and it's working
I think you make some mistake on the header mediator. "HelloWorld" back end service didn't need the SOAP header based on your SOAP UI request. so remove the header mediator.
Select Synapse if you want to manipulate SOAP headers. Select Transport if you want to manipulate HTTP headers.
And it's seems back end is SOAP11, SOAP11 type is "text/xml". Your may need set this property.
<property name="messageType" value="text/xml" scope="axis2"/>
When you send message out from ESB, you need set property "messageType", then ESB will formatter the message that match back end required.
You may probably need this property, if you found ESB append some context to your back end URI when send message to back end.
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
Good Tips:
Please open your "synapse.transport.http.wire" as DEBUG, this will output every message in and out from ESB. This log will including HTTP header and body. After you got the wire log, you can compare wire log with your SOAPUI request, then find out which part is wrong.
https://docs.wso2.com/display/ESB481/Setting+Up+Logging
new to WSO2 but trying to do something that should be relatively straightforward even for the uninitiated, before I have a crack at some xslt mediation in a wso2 proxy.
All im trying to do as a first step is change the transport between the wso2 client (jms) and the endpoint (http). The client is sending a full soap envelope in the JMS payload.
I can see that my endpoint is being invoked from the server logs (however I can see requests are rejected).
Sure enough, I can see from the proxy logs that WSO2 is adding an additional SOAP envelope wrapper around the soap payload from the client.
My understanding is that this should be correctable by setting the format attribute of the endpoint to "leave as-is". This doesnt make a difference however. I suspect this is an easy endpoint or proxy configuration fix, rather than requiring some xsl mediation? Any guidnace gratefully received:
my code:
Endpoint:
<endpoint xmlns="http://ws.apache.org/ns/synapse">
<address uri="http://d26li228.au.alcatel-lucent.com:44006/ilws/InstantLinkSOA">
<suspendOnFailure>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
<retryDelay>0</retryDelay>
</markForSuspension>
</address>
</endpoint>
Proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="McProxy3"
transports="McJMS"
statistics="disable"
trace="enable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint key="conf:/ilepr"/>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<parameter name="transport.jms.Destination">McQueue</parameter>
<description/>
</proxy>
Set the content type of the message you are receiving from JMS : if there is already a SOAP Envelope, it's text/xml :
<parameter name="transport.jms.ContentType">
<rules xmlns="">
<jmsProperty>contentType</jmsProperty>
<default>text/xml</default>
</rules>
</parameter>
If the service you're calling through your endpoint wait soap11 or soap12, you can set this format in your endpoint definition (don't let "leave as-is")
You've defined OUT_ONLY to true inside your inSequence, before sending your message through your endpoint : the ESB won't instanciate any callback and will not receive any response (outSequence will never be executed)
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>
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>