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

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

Related

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

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

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 log Http request in log mediator

Is there a way to include the http request remote host in the log mediator being used for a specific api?
Having followed the instructions, i can log the soap message, but i have no info regarding the caller of the service.
I currently use the following sequence definition:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--In">
<log level="full">
<property name="TRACE" value="Gunet Mediation Extension"/>
</log>
</sequence>
And the result i get when having a call is the following:
INFO - LogMediator To: /SmartSearch/1, WSAction: urn:SearchStudentStatus, SOAPAction: urn:SearchStudentStatus, MessageID: urn:uuid:36f9a5cd-c8cb-4e1e-97a6-f3ebd3303589, Direction: request, TRACE = Gunet Mediation Extension, Envelope: <?xml version='1.0' encoding='utf-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><SearchStudentStatus xmlns="gunet.gr"><SSN>12312312312</SSN><institution>aueb</institution></SearchStudentStatus></S:Body></S:Envelope>
I would like to have information about the remote host that made the specific call. Is that possible, using the log mediator, or should i use a combination of log4j configs?
Thanks!
You can get the remote IP which call the API using following property mediator.
<log level="full">
<property name="Actual Remote Address" expression="get-property('axis2','REMOTE_ADDR')"/>
</log>

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.

WSO2 APIM Gateway 1.6.0 inserts end of chunk character even if Content Length should be 0

We are trying to remove the end end of HTTP chunk character inserted by WSO2 APIM Gateway in HTTP body responses even if the Response Body should be empty (204 Status code).
We are using WSO2 API manager 1.6.0, whenever it receives a message without Content Type (example response Status code 204 No Content) , WSO2 API Manager Gateway includes the Header "Transfer-Encoding : chunked" with a Content Body with 0 (length 5) end of chunk 0\r\n.
In this case a Content-Length of 0 is expected with a completely empty content body.
1) We tried without success first to insert the the following lines in our API definition to enforce a content length of 0 :
under $CARBON_HOME/repository/deployment/server/synapse-configs/default/api/ :
<outsequence>
<property name="FORCE_HTTP_CONTENT_LENGTH" scope="axis2" value="true"></property>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" scope="axis2" value="true"> </property>
<send></send>
</outsequence>
2) We tried also without success to insert the following lines to disable chunk encoding as described in the WSO2 doc (https://docs.wso2.com/display/ESB450/HTTP+Transport+Specific+Properties) :
<outsequence>
<property name="FORCE_HTTP_1.0" value="true" scope="axis2" />
<property name="DISABLE_CHUNKING" value="true" scope="axis2" />
<send></send>
</outsequence>
3) We also tried to insert these lines within the markups of the API xml definition without success.
Incoming HTTP reponse to WSO2 APIM Gateway :
HTTP/1.1 204 No Content
Server: Apache-Coyote/1.1
Date: Fri, 08 Aug 2014 14:02:57 GMT
Outgoing HTTP response out of WSO2 APIM Gateway :
HTTP/1.1 204 No Content
Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type
Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
Date: Fri, 08 Aug 2014 13:56:50 GMT
Server: WSO2-PassThrough-HTTP
Transfer-Encoding: chunked
0
Could you please help us to solve this issue ?
Thanks a lot for your support
JS
Try adding this property mediator to disable chunking:
<property name="DISABLE_CHUNKING" value="true" scope="axis2"/>
This property mediator can be used in custom insequences and outsequences. You can also add it to your API templates. Here is a blog post about applying this to the templates:
http://hoosierapi.blogspot.com/2014/07/wso2-api-manager-proxing-without.html
Cheers,
Colin