Is there any method in WSO2 EI to get the status code description from the http response - wso2

Is there any method in wso2 EI to get the status code names like "ok", "internal server error" etc..
Access the status name(text) not code to show in postman.
I got the status code by $axis2:HTTP_SC, and now I want the status code message.

You can use the following property for this.
<property expression="$axis2:HTTP_SC_DESC" name="Description"/>
<property expression="$axis2:HTTP_SC" name="Code"/>

Related

SMS is not received to mobile in SMPP Connector - WSO2 EI 6.5.0

I am using WSO2 SMPP Connector to send SMS to mobile number in WSO2 EI 6.5.0
Pre-requisites:
Setup done by using the same steps mentioned here
I just placed jsmpp-2.1.0-RELEASE.jar into <PRODUCT_HOME>/lib
logica-smpp-sim simulator set up done and it is running with the port 10003 in windows 10
API:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/send" name="SmppTestApi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<property expression="json-eval($.distinationAddress)" name="distinationAddress" scope="default" type="STRING"/>
<property expression="json-eval($.message)" name="message" scope="default" type="STRING"/>
<property expression="json-eval($.sourceAddress)" name="sourceAddress" scope="default" type="STRING"/>
<SMPP.init>
<host>localhost</host>
<port>10003</port>
<systemId>justin</systemId>
<password>justin</password>
<systemType>UNKNOWN</systemType>
<addressTon>UNKNOWN</addressTon>
<addressNpi>UNKNOWN</addressNpi>
</SMPP.init>
<SMPP.sendSMS>
<sourceAddress>{$ctx:sourceAddress}</sourceAddress>
<distinationAddress>{$ctx:distinationAddress}</distinationAddress>
<message>{$ctx:message}</message>
</SMPP.sendSMS>
<log level="full">
<property name="Message delivered sucessfully" value="Message delivered sucessfully"/>
</log>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
When I hit API , it is giving proper response as mentioned here
Postman:
Logica-sim log:
03:16:07 [justin] client request: (submit: (pdu: 108 4 0 3) (addr: 0 0 16111) (addr: 0 0 919047878787) (sm: msg: Hi! This is the first test SMS message.) (opt: ) )
03:16:07 [justin] putting message into message store
03:16:07 [justin] server response: (submit_resp: (pdu: 0 80000004 0 3) Smsc2002 )
WSO2 EI Log:
[2022-10-18 15:16:07,349] [] INFO - LogMediator To: /send, MessageID: urn:uuid:052d3fb7-1762-4323-bea1-5302ddc93d36 correlation_id : e5990fb5-fd97-45d2-b971-878d2471d9e5, Direction: request, Message delivered sucessfully = Message delivered sucessfully, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:messageId xmlns:ns="http://org.wso2.esbconnectors.smppConnector">Smsc2002</ns:messageId></soapenv:Body></soapenv:Envelope>
Note: I passed valid Indian Mobile number in the input request field (ie "distinationAddress")
I think SMS is stored in SMSC, But SMPP inbound endpoint will consume SMS from SMSC and send that to WSO2 EI Sequence.
I just want to understand in which stage SMS will send to corresponding mobile number which we passed in API Request.
Even though Received proper response SMS is not received to mentioned mobile.
Do I need to make any other configuration in API SMPP init level to send SMS? Kindly clarify on this.
The document you pointed out has this.
For testing purposes, it is not practical always to connect with a
real SMSC. SMSC Simulator is an application that can act like an SMSC.
Using a simulator we can test our scenario without having access to a
real SMSC. For the real production servers we have to use a real SMSC.
In this example scenario we will be using logica-smpp-sim simulator.
According to the above logica-smpp-sim is just a simulator, which is used to mimic an actual SMSC for testing. So I don't think it would send SMSs. You may have to connect to a real/production grade SMSC/SMPP Provider or an SMS Gateway if you want to send SMS. You can read more about the SMPP protocol and available Gateways from here.

WSO2 API Manager: Always got HTTP OK response regardless of HTTP status code

I tried to set HTTP status code in response message in a custom mediator as followed
<property name="HTTP_SC" value="400" scope="axis2"/>
But in the response I got this status line
HTTP/1.1 400 OK
Is there anything else I need to do to get the correct HTTP status message which align with the HTTP status code.
I am using WSO2 API Manager 2.0.0
Thank you very much.
After dumping all properties in axis2 context, I found that I have to remove a property called 'HTTP_SC_DESC' to have HTTP status description correctly set
<property name="HTTP_SC_DESC" scope="axis2" action="remove"/>
After that I got correct HTTP status description
HTTP/1.1 400 Bad Request

Error with WSO2 ESB when trying to connect to Jira and ElasticSearch

I have and scenario where I want to extract dynamically Issues from Jira in order to save them on ElasticSearch. I use a custom Proxy Service that connect with Jira (via Jira connector), get a project (first I want to save the project's information) and pass this information to Elastic. Following is the in Sequence of the proxy service:
<?xml version="1.0" encoding="UTF-8"?>
<inSequence xmlns="http://ws.apache.org/ns/synapse">
<property expression="json-eval($.username)" name="username"/>
<property expression="json-eval($.password)" name="password"/>
<property expression="json-eval($.uri)" name="uri"/>
<property expression="json-eval($.id)" name="id"/>
<property expression="json-eval($.uriEl)" name="uriEl"/>
<property expression="json-eval($.indexName)" name="indexName"/>
<property expression="json-eval($.type)" name="type"/>
<property expression="json-eval($.message)" name="message"/>
<jira.init>
<username>{$ctx:username}</username>
<password>{$ctx:password}</password>
<uri>{$ctx:uri}</uri>
</jira.init>
<jira.getProject>
<projectIdOrKey>{$ctx:id}</projectIdOrKey>
</jira.getProject>
<property expression="json-eval($.project)" name="project"
scope="default" type="STRING"/>
<elasticsearch.init>
<apiUrl>{$ctx:uriEl}</apiUrl>
</elasticsearch.init>
<elasticsearch.createDocumentWithIndex>
<indexName>{$ctx:indexName}</indexName>
<type>{$ctx:type}</type>
<message>{$ctx:message}</message>
<body>{$ctx:project}</body>
</elasticsearch.createDocumentWithIndex>
<respond/>
</inSequence>
And here is the sample request:
{
"username":"MyName",
"password":"AnStrongPassword",
"uri":"JiraURL",
"id":"MyProject",
"uriEl":"http://localhost:9200",
"indexName":"jira",
"type":"project",
"message":"Testing"
}
The other parameters (Endpoint, out Sequence and Fault Sequence) are by default.
The problem is that when I try to send this request via 'Try the Test service' option on WSO2 ESB, i get the following error:
Error connecting to the Tryit ajax proxy
I have tested the same code but only using the Jira connection (without get a project or connect to Elastic), and the same error occurs.
Looking to this error, I suppose that the problem is before to read the JSON request, but I don't know if it is related to the endpoint (I think that it is not necessary an endpoint for this scenario).
Thanks in advance.
This problem is totally independent of the jira connector etc. Problem is with the "try it" tool. This tool is not that much recommended for testing purposes. Instead of that, try invoking the proxy service via soap ui.
If you share a screenshot when the try it error occurs, I'll be able to comment on that as well.
After a few days I have found another solution to my problem without using proxy services. To connect ESB with Jira, I created this API on ESB:
<api xmlns="http://ws.apache.org/ns/synapse" name="transport_service" context="/transport_service">
<resource methods="GET">
<inSequence>
<jira.init>
<uri>MyURL</uri>
<username>MyUser</username>
<password>3MyPass</password>
</jira.init>
<jira.searchJira>
<query>project=MyProject</query>
<maxResults>50000</maxResults>
<fields>MyField1,MyField2,etc</fields>
</jira.searchJira>
<respond/>
</inSequence>
<outSequence>
<log level="full"/>
<property name="messageType" value="application/xml" scope="axis2"/>
<send/>
</outSequence>
</resource>
</api>
The command to call this API is simple:
curl -v -X GET http://localhost:8280/transport_service > jira-db.json
Finally, if you want to insert this json on elastic, you can follow the typical PUT via curl:
curl -XPUT 'http://localhost:9200/jira/jira/1' -d #jira-db.json
Additionally, you can write both commands on a daily bash script (using your scheduled task list), getting the same result that scheduling your proxy service on WSO2ESB:
#!/bin/bash
curl -v -X GET http://localhost:8280/transport_service > jira-db.json
curl -XPUT 'http://localhost:9200/jira-dev/jira/1' -d #jira-db.json
echo "Daily load completed"

WSO2 ESB: how to carry a SOAP answer into a file (or DB) using a scheduled task

I deploy a proxy service in WSO2 ESB that asks a web service for a dataset by a SOAP request and the web service correctly returns the requested dataset. In order to have evidence of the right answer of the web service, how can I do to store this dataset into a generic file during a regular scheduling in a task?
In your proxy def, you can find :
a inSequence executed when a request is sent to this proxy,
a outSequence that receive a response if you send a request from your inSequence (with send mediator)
a faultSequence executed if an error occurs.
So, if you "asks a web service for a dataset" from your inSequence using send mediator, your outSequence receive the response (your "dataset") and you just have to send it to a file :
<!-- name of the file -->
<property name="transport.vfs.ReplyFileName" value="dataset.xml" scope="transport"/>
<!-- OUT_ONLY because we want to use send mediator but don't want a callback waiting for a response -->
<property name="OUT_ONLY" value="true" />
<!-- Send current message (the response from your webService) to the filesystem : test directory must exist on c:\ -->
<send>
<endpoint>
<address uri="vfs:file:///C:/test"/>
</endpoint>
</send>
--> don't forget to activate VFS sender in repository/conf/axis2/axis2.xml : uncomment <transportSender name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportSender"/>

How to handle Endpoint warnings in wso2esb

I am using wso2 esb 4.8.1,
I wish to handle warning of endpoints.I am trying to hit CXF services in tomcat server.
If I test with wrong action (Operation/method)name or service name in tomcat.
I am getting this message in SOAP.
<html>
<body>No service was found.</body>
</html>
Where as in my wso2esb not getting logged any error and that particular endpoint failing showing this message.
[2014-11-24 16:57:57,931] WARN - LoadbalanceEndpoint Endpoint [ServiceLEP] Detect a Failure in a child endpoint : Endpoint [EP3]
Since I don't know the CXF I wish to handle this in wso2esb How would I handle this message and send proper error response to client.
Is any one able to help me.
Thanks in advance.
If you are using a mediator, the response will be available in the inSequence. You can log that response with code such as this after your mediator:
<enrich>
<source type="body"/>
<target type="property" action="child" property="response_body"/>
</enrich>
<log level="custom">
<property name="The Response" expression="get-property('response_body')"/>
</log>
Please advise if that works in your scenario.
If your endpoint is suspended, then WSO2 by default initiate fault sequence, you can define your custom message in the fault sequence and then send it back to the client as you want. You can get ERROR_CODE and ERROR_MESSAGE property from WSO2 in Log or Switch mediator where u can check it. In log u can do it as following:
<log level="full" separator="**********Fault Sequence File Processor***********">
<property name="ErrorCode" expression="get-property('ERROR_CODE')"></property>
<property name="ErrorMessage" expression="get-property('ERROR_MESSAGE')"></property>
<property name="ErrorDetail" expression="get-property('ERROR_DETAIL')"></property>
<property name="ErrrorException" expression="get-property('ERROR_EXCEPTION')"></property>
</log>
You can make a check on ERROR_CODE property or ERROR_MESSAGE property in Switch mediator and then with the help of Payload mediator u can define your custom error message.