I am currently playing around with the WSO2 enterprise service bus, some cxf based webservices and mtom attachments.
Using SoapUI (MTOM enabled), I submit the following request to one backend service:
...
<incident>
....
<attachmentList>
<attachment>
<contentID>cid:soapui32.png</contentID>
</attachment>
</attachmentList>
</incident>
...
With MTOM enabled Raw data is
...
<attachmentList>
<attachment>
<contentID>
<inc:Include href="cid:soapui32.png" xmlns:inc="http://www.w3.org/2004/08/xop/include"/>
</contentID>
</attachment>
</attachmentList>
...
------=_Part_0_22113723.1360006252844
Content-Type: image/x-png; name=soapui32.png
Content-Transfer-Encoding: binary
Content-ID: <soapui32.png>
Content-Disposition: attachment; name="soapui32.png"; filename="soapui32.png"
......
So far, so good.
Now, as the next step, I create a WSDL based proxy service (WSO2 ESB 4.5.1) for this webservice.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="testService" transports="https,http" statistics="enable" trace="enable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<wsdl service="IncidentService" port="IncidentServicePort" uri="uri2myservicewsdl"/>
</endpoint>
</target>
<publishWSDL uri="uri2myservicewsdl"/>
<description></description>
</proxy>
enableMTOM is set to true in the axis2.xml, MTOM is enabled for the proxy service.
If I submit exactly the same request with the same attachment via SoapUI, the esb transforms the attachment to inline content (debug log):
DEBUG - Starting Activation Handler invocation. Incoming Message:
......
<incident>
<attachmentList>
<attachment>
<contentID>iVBORw0KGgoAAAANSUh.....</contentID>
</attachment>
</attachmentList>
</incident>
.....
</soapenv:Body></soapenv:Envelope>
{org.wso2.carbon.activation.module.ActivationHandler}
Where can I enable MTOM, so that the proxy doesnt transform it to inline content?
Many thanks in advance.
Workaround
Maybe someone is interested, even if it's just a workaround:
I had enabled MTOM and SwA attachments in the axis2.xml (wso2 esb conf directory).
As soon as I disabled SwA and only left MTOM enabled, attachments are not transformed to inline content any more.
Now SwA is disabled for all proxy services, but that's ok for the moment.
I will have another look at it later, maybe it's a bug.
Related
Hi I am trying to use Data Service Call. When I use it in any proxy service in wso2 I get an error Unknown mediator referenced by configuration element: dataServiceCall
https://apim.docs.wso2.com/en/latest/reference/mediators/dss-mediator/
I am following the link as mentioned above. Can someone guide me what am I doing wrong ?
Below is the code I have written
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="TestData" startOnLoad="true" transports="http https local" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<dataServiceCall serviceName="Hello">
</dataServiceCall>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
</proxy>
Probably this has to do with the version of the Integration Studio you are using. It seems the IDE is unable to find the DataServiceCall Mediator. First, try updating the Integration Studio referring this document. If that doesn't work, try using a newer version of the Integration Studio.
Once updated the Dataservicecall Mediator should be listed under the Mediators section.
You are calling a dataservice but you didn't initiate this dataservice project before,so you have to make a dataservice before calling this dataservice from the proxy service.After that a design of "dataServiceCall " will appear in the integration Studio.
I am trying to publish API in wso2 API Manager. But I am using basic security with my authorization key. I am getting a type error: Failed to execute 'fetch' on 'Window': Invalid name. I tried to change the swagger file. But didn't get the required response.
If you are trying to send a header to your backend through APIM, you have define it as a header under resources in the Publisher portal.
However, if the name of your header is Authorization you will have to use some sort of a mediation to send this to your backend. For example,
<sequence xmlns="http://ws.apache.org/ns/synapse" name="KeyExchange">
<property name="Custom" expression="get-property('transport', 'Custom')"/>
<property name="Authorization" expression="get-property('Custom')" scope="transport"/>
<property name="Custom" scope="transport" action="remove"/>
</sequence>
If you add the above to your in-sequences, you will have to send a header called Custom with the key you need to send to the backend. Then APIM will replace this Custom header with Authorization header when sending the request out from APIM.
If you have enabled Basic auth for your API created in APIM, you need to follow [1] to invoke the API.
I managed to configure a websocket service in Knox which for test purposes is ws://echo.websocket.org
Here are my configuration files:
service.xml
<service role="ECHOWS" name="echows" version="0.0.1">
<policies>
<policy role="webappsec"/>
<policy role="authentication" name="Anonymous"/>
<policy role="rewrite"/>
<policy role="authorization"/>
</policies>
<routes>
<route path="/echows">
<rewrite apply="ECHOWS/echows/inbound" to="request.url"/>
</route>
</routes>
</service>
rewrite.xml
<rules>
<rule dir="IN" name="ECHOWS/echows/inbound" pattern="*://*:*/**/echows">
<rewrite template="{$serviceUrl[ECHOWS]}"/>
</rule>
</rules>
{topology}.xml section:
<service>
<role>ECHOWS</role>
<url>ws://echo.websocket.org</url>
</service>
I can connect to it:
wscat -c wss://my-knox-server/gateway/default/echows
connected (press CTRL+C to quit)
> Hello Knox!
< Hello Knox!
But I'd like Knox accept connection only when proper credentials are given:
wscat --auth <username:password> -c wss://my-knox-server/gateway/default/echows
My Knox configuration for http services works in this way that I have to put credentials, otherwise I get 401:
curl -i https://my-knox-server/gateway/default/my_service/ping
HTTP/1.1 401 Unauthorized
curl -i -u '<user>:<password>' https://my-knox-server/gateway/default/my_service/ping
HTTP/1.1 200 OK
I'd like to achieve the same result with websockets.
[EDIT]
Moreover I don't fully understand the above service.xml configuration for my websocket service, since it is different than the simplest possible configuration for a http service I was able to use:
<service role="MY_APP" name="my_app" version="0.0.1">
<routes>
<route path="/my_app/**"/>
</routes>
</service>
Why in case of a websocket service I need policies, and what do they mean?
Why <routes>/<route> has an element <rewrite> and what is its semantics? Does it correspond to <rule>/<rewrite> from rewrite.xml? What does request.url mean there?
Good question, unfortunately the Authentication and Authorization mechanism in Knox is based on Http servlet filters which won't be applicable for Websocket.
One thing you can do is have a HTTP side that does the authentication and then opens up the websocket connection.
If you want you can open up a JIRA for this enhancement.
[EDIT]
Answers to followup questions
In case of Websockets have no meaning, they are artifacts from http
Again the in rewrites can be explained better with http context than with websocket. What they do is, tell Knox when to apply the rewrite rule i.e. request.url, request.body, response.url, response.body etc. Since, rules are based on HTTP servlet filters they are not used to rewrite websocket data. I believe there should be some JIRA lying around for that.
I’m exploring the use of topics and events in WSO2 ESB 4.8.1, I created a topic and subscribed to it the endpoint of one dataservice running in WSO2 WSAS(A), I supposed that if I published a message with the structure defined for the incoming message of one of A operations in the publish tool of the Topic Details console, the message would be sent to the supscriptor (A) and everything where going to work fine, but it don’t. Why?
I also create a proxy service with an event mediator and configured the event mediator with the name of the created topic. Then I Try the proxy service with an incoming message with the same structure explained before. I was expecting to at least get an incoming message in the WSAS Soap Tracer, but nothing happened.
Am I missing something?
The eventing infrastructure is based upon the WS-Eventing specification. Since you are using a WSDL based service as a subscriber of the topic and intend to invoke a specific operation of that service, I imagine it is failing because the SOAP message and/or SOAP action are incorrect because the message sent to the topic and the service are based around WS-Eventing and not your service.
I created the simple proxy below and subscribed it to a topic.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="LogSubMessage" transports="http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full" category="ERROR">
<property name="SERVICE" value="LogSubMessage"/>
</log>
</inSequence>
<outSequence><send/></outSequence>
</target>
</proxy>
I then sent a <test/> message to the topic.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ns:topic xmlns:ns="http://wso2.org/ns/2009/09/eventing/notify">topicname</ns:topic>
</soapenv:Header>
<soapenv:Body>
<test/>
</soapenv:Body>
</soapenv:Envelope>
As you can see in the message above, the message logged in the service contains WS-Eventing SOAP headers and the SOAP action was set to http://ws.apache.org/ws/2007/05/eventing-extended/Publish . If your data service requires that the SOAP header contain the name of the operation to invoke, then it would reject this request.
I would suggest creating a proxy service, similar to the the one above, that would subscribe to the topic. This service would set the correct SOAP action, perform any message transformations you need, and call your data service.
I'm facing up to the load balance algorithm implementation for customizing the load balance endpoint.
On this documentation page:
http://docs.wso2.org/display/ESB470/Load-balance+Endpoint
I read:
Algorithm - Either a default "Round-robin" or custom loaded algorithm of the group. See more information about this algorithm in the article.
Where "article" is a link point to this page:
http://supunk.blogspot.it/2010/02/writing-load-balance-algorithm-for-wso2.html
But the referred article is not complete and doesn't tell anything about the algorithm development. Could anyone give me a valid example?
You can use below sample to send multiple request to share between diffent endpoint using RoundRobin algo.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestLoadBalance"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<endpoint>
<loadbalance algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService/"/>
</endpoint>
<endpoint>
<address uri="http://localhost:9001/services/SimpleStockQuoteService/"/>
</endpoint>
<endpoint>
<address uri="http://localhost:9002/services/SimpleStockQuoteService/"/>
</endpoint>
</loadbalance>
</endpoint>
</target>
<description/>
</proxy>
As the documentation specifies, the algorithm should be an implementation of org.apache.synapse.endpoints.algorithms.LoadbalanceAlgorithm
You need to write a class implementing LoadbalanceAlgorithm interface. You can refer the existing implementations RoundRobin, WeightedRRLCAlgorithm and WeightedRoundRobin classes found in org.apache.synapse.endpoints.algorithms package.
Then create a jar file with your class and add it to <ESB_HOME>/repository/components/lib folder and restart the server.
Now when adding a Load Balance Endpoint, select Other... for the Algorithm and provide the full classname of your custom algorithm. For example: org.apache.synapse.endpoints.algorithms.WeightedRoundRobin
Looking at
LoadBalanceAlgortihm it's not possibile to simply give it a dynamic list of endpoint.
Concerning LoadBalanceMambershipHandler and its implementation (Axis2 and Service)...it uses object like:
org.apache.axis2.clustering.management.GroupManagementAgent
and
org.apache.axis2.clustering.ClusteringAgent
so you have to configure your nodes in cluster using the axi2.xml inside /repository/conf/axis2 folder of your ESB.
Use the ESB registry to save the loadbalance enpoint in and then access it by code for adding it a new list of address endpoint.