This is my first question, so see my effor and answer my question :)
I need to get address of server, so I got server IP with this property
<property expression="get-property('SERVER_IP')" name="StringServerIp" scope="default" type="STRING"/>
I tried this property to get the port number ,and it returns null <property expression="get-property('system.port.no')" name="system.port.no"/>
Please help me to get port number of sender
any idea or any refering are appreciated
Try this.
<script language="js">mc.setProperty("port",java.lang.System.getProperty("xxxx"));</script>
<log level="custom">
<property name="port" expression="get-property('port')"/>
</log>
Here xxxx can be one of below.
mgt.transport.http.port
mgt.transport.https.port
http.nio.port
https.nio.port
Related
I tried to create a custom policy, with a purpose a mask of service:
Original Services in API:
http://API/v1/profile
http://API/v1/account
With mask:
http://API/v1/user-profile
http://API/v1/user-account
And combination the answer of User Bee this a solution for this problem:
<switch source="get-property('axis2', 'REST_URL_POSTFIX')">
<case regex="/v1/kyc-profile">
<property name="REST_URL_POSTFIX" value="/v1/profile" scope="axis2"/>
</case>
<case regex="/v1/kyc-account">
<property name="REST_URL_POSTFIX" value="/v1/account" scope="axis2"/>
</case>
</switch>
But this solution only works where the services is static, but I have others services, similar to:
http://API/v1/user-profile/{id-user}/details
http://API/v1/user-profile/{id-user}?expand=some_information
For the last service I have this:
<switch source="get-property('axis2', 'REST_URL_POSTFIX')">
<case regex="v1/user-profile/[\/\w\W]*">
<property name="REST_URL_POSTFIX" value="/v2/cliente/{id-user}?expand=some_information" scope="axis2"/>
</case>
</switch>
[/\w\W]* This part is regular expression for {id-user}?expand=some_information and similar.
The problem is: I need put dynamic value because the property value (<property name="REST_URL_POSTFIX" value="THIS" scope="axis2"/>) takes this text, example:
Service before to policie
http://API/v1/user-profile/1?expand=some_information
Service after to policie
http://API/v1/user-profile/{id-user}?expand=some_information
My questions are:
How to put a dynamic value for the services similar to: http://API/v1/user-profile/{id-user}?expand=some_information?
For the other service, http://API/v1/user-profile/{id-user}/details I have the similar situacion, How a resolve?
In your mediation sequence, try changing the backend URL as follows.
http://API/v1/user-profile/{uri.var.id-user}?expand=some_information
Example:
<switch source="get-property('axis2', 'REST_URL_POSTFIX')">
<case regex="v1/user-profile/[\/\w\W]*">
<property name="REST_URL_POSTFIX" value="/v2/cliente/{uri.var.id-user}?expand=some_information" scope="axis2"/>
</case>
</switch>
I need to use tokenize function in my wso2 sequence file.
I am getting the username like testuser#gmail. I need to split the string using the delimeter #. I am using the below code.
. But, It is always printing blank in logs.
Could you please some one help me.
PS:: I have enabled xslt2.0 in my synapse.properties file.
Use the substring-before function
<property name="tokentest" value="testuser#gmail" scope="default" type="STRING"/>
<property name="NEW_CONTENT_TYPE" expression="substring-before($ctx:tokentest,'#')" scope="default" type="STRING"/>
<log level="custom">
<property name="NEW_CONTENT" expression="$ctx:NEW_CONTENT_TYPE"/>
</log>
Hope this helps
I am using WSO2 4.9.
I have a simple endpoint defined as such
<endpoint name="someEndpoint">
<address uri="someAddress" format="soap11">
</endpoint>
This specific endpoint also requires basic HTTP auth, which I provide like this:
<property name="Authorization" description="Set-User-Pwd" expression="fn:concat('Basic ', $ctx:authorizationProperty)" scope="transport" type="STRING"/>
I make a simple call towards it like this:
<call description="Some description">
<endpoint key="someEndpoint"/>
</call>
I should note that the server which I'm attempting to call:
responds with a SOAP answer (i.e. proper XML, etc) when all is good
responds with a HTML answer when authorization errors happen
The problem I'm having concerns the situation when I'm passing it a wrong user. I'm expecting that in this scenario, my fault sequence would get invoked (the above is part of an api declaration, which also has a fault sequence).
But this doesn't happen, and I get the following error:
Caused by: com.ctc.wstx.exc.WstxParsingException: Unexpected close tag </body>; expected </HR>.
at [row,col {unknown-source}]: [1,1054]
I suspect this is happening because WSO2 attempts to parse my HTML response as if it were XML, and fails (which is understandable). I also suspect that this happens before any error sequence gets invoked, etc, and hence my problem.
Edit1: At the beginning of my outSequence, I have a log line which isn't getting printed. So I don't think this is something caused by whatever mediators are in outSequence.
<outSequence>
<log level="custom">
<property name="message" value="OUT call!!!!!!!!!!!!!!!!!!!!!!!" />
</log>
...
</outSequence>
Edit2: Some more details about inSequence.
It contains these lines, which seem to make no difference on the error message (i.e. I get the same if I remove).
<property name="messageType" scope="axis2" value="application/xml"/>
<property name="ContentType" scope="axis2" value="application/xml"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove" />
What can I do in this situation in order to be able to catch these errors? I should note that I don't particularly care about the text in the body (I'm only interested in HTTP status code and maybe HTTP status message).
I have a text file on my local system I wish to append the data in particular file as synchronously.
I have tried many ways, but it's not working.
ESB has this future in Oracle SOA. We can add in FILE ADAPTER. In ESB it's neither giving errors nor expected result.
My configuration is like this:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="FileWrite" transports="http,vfs" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log>
<property name="OUT_ONLY" value="true"/>
</log>
</inSequence>
<outSequence>
<log>
<property name="OUT_ONLY" value="true"/>
</log>
<payloadFactory>
<format>
<error>error404</error>
</format>
</payloadFactory>
<send>
<endpoint>
<address uri="vfs:file:///home/youtility2/Desktop/Errorlog"/>
</endpoint>
</send>
</outSequence>
</target>
<parameter name="transport.vfs.ReplyFileURI">file:///home/user/test/out? transport.vfs.Append=true</parameter>
<parameter name="transport.PollInterval">10</parameter>
<parameter name="transport.vfs.FileNamePattern">Errorlog.text</parameter>
<parameter name="transport.vfs.ContentType">text/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.ReplyFileName">Errorlog.xml</parameter>
<description></description>
</proxy>
Actually I kept a log mediator in outSequence. The inSequence mediator is not sending the data in to the outSequence process not forwarding into outSequence. That's why I think that the above configuration is not working.
Any reference for this?
I tried above configuration in inSequence also. It's giving errors like this:
ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.AxisFault:
The VFS transport doesn't support synchronous responses. Please use
the appropriate (out only) message exchange pattern
Please refer to this link.
The issue is, you are setting a property inside a log mediator which is a predefined property, (ie:OUT_ONLY) which is used to indicate the request is only the "out-only" request. So, system, wont expect the response back. That is why, you are not getting anything in your outsequence.
DO NOT USE the predefined properties in the Log mediator,which will cause issues.
Keep some text in the log meditaor to indictae the flow of the message.
eg:
<inSequence>
<log>
<property name="INSEQUENCEEEEEEE" value="********"/>
</log>
</inSequence>
Like wise keep different descriptive log in the outsequence and see whether you are getting the message there, without any issue.
I am trying to access external web services (outside of intranet) using WSO2 ESB 4.0.3 but I do not know how to configure the proxy to let the request go outside. I can send SOAP messages over HTTP from my basic Java client app without issues; I could specify teh proxy details using Apache HttpComponents. So, connection details are OK.
I tried:
Editing <transportSender name="http" ... > and specifying parameters like "http.proxyHost" and "http.proxyPort".
Setting up a global parameter <parameter name="Proxy"> ...
Configuring the HTTP Transport Sender and specifying the appropriate parameters.
The best I got was:
ERROR_CODE = 101503, ERROR_MESSAGE = Connection refused or failed for : ...
So, what did I wrong and what should I do instead? Thanks.
Does your proxy server has any authentication? If yes and it uses Basic Auth you need to specify followoing properties before sending out the request..
<property name="Proxy-Authorization" expression="fn:concat('Basic', base64Encode('userName:password'))" scope="transport"/>
<property name="POST_TO_URI" value="true" scope="axis2"/>
The first property sets the Proxy-Authorization HTTP transport header with the base64 encoded user name and password as expected by the HTTP basic authentication.
The second property makes the out-going URL a complete URL understandable by the Proxy Server.
Following is an example proxy config...
<proxy name="StockQuoteProxy" startOnLoad="true">
<target>
<inSequence>
<property name="Proxy-Authorization" expression="fn:concat('Basic ', base64Encode('udayanga:test123'))" scope="transport"/>
<property name="POST_TO_URI" value="true" scope="axis2"/>
<send>
<endpoint>
<address uri="http://www.wso2.com:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>