I'm unable to call third party rest api(https://api.github.com/users/hackeryou) in wso2 ei and wso2 esb.
Below is the sample code:
<api xmlns="http://ws.apache.org/ns/synapse" name="VerifyCustID" context="/mambu">
<resource methods="GET" uri-template="/verify">
<inSequence>
<log>
<property name="CustID API" value="*********Inside CustID API********** "/>
</log>
<send>
<endpoint>
<http method="GET" uri-template="https://api.github.com/users/hackeryou"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
Below is the error in server log:
ID API = *********Inside CustID API**********
[2017-07-14 15:01:48,756] [] WARN - ConnectCallback Connection refused or failed for : api.github.com/192.30.253.116:443
[2017-07-14 15:01:48,759] [] WARN - EndpointContext Endpoint : AnonymousEndpoint with address https://api.github.com/users/hackeryou will be marked S
USPENDED as it failed
[2017-07-14 15:01:48,760] [] WARN - EndpointContext Suspending endpoint : AnonymousEndpoint with address https://api.github.com/users/hackeryou - cur
rent suspend duration is : 30000ms - Next retry after : Fri Jul 14 15:02:18 IST 2017
[2017-07-14 15:01:48,772] [] INFO - LogMediator To: https://api.github.com/users/hackeryou, MessageID: urn:uuid:7b834e0e-e348-4b60-adeb-f60a70f00483,
Direction: request, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 101503, ERROR_MESSAGE = Error connecting to the back end, Envelope: <?
xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>
You might have some network connectivity issue to api.github.com:443 (perhaps firewalls etc.)
The API worked fine for me on EI611:
If you are not using the default truststore (client-truststore.jks) that comes with WSO2 or have made changes to it, you might need to import the certificate for api.github.com into the trust store that your WSO2 server is actually using.
Apart from network connectivity and missing certificate in trust store, can't see why your API shouldn't be able to call the remote service
Related
I have created a Data Service (DS) and expose the data as a REST resource. and I could successfully retrieve data via CURL command given below.
curl -X GET -H "Accept: application/json" http://localhost:8280/services/TestDataService.HTTPEndpoint/Member/0
The REST API resource template is Member/{MemberID} - DS Endpoint
The response is,
{"Members":{"Email":"example#test.com","FirstName":"Mad","MembershipCategory":"Gold","InsuranceType":"Health","LastName":"Tim"}}
Then I wanted to convert this JSON response to a CSV using WSO2 EI's Data Mapper mediator. I know there are alternative ways to achieve this usecase via other mediators or WSO2 API manager.
I created another API resource in WSO2 EI which has the template
/convertDetails/Member/{MemberID} - EI Endpoint
Anyhow, with following configurations, I could not get the correct response when I call the REST API resource from a REST client.
Following is my mediation flow,
<?xml version="1.0" encoding="UTF-8"?>
<api context="/convertDetails" name="MemberDetailsConversion" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/Member/{MemberID}">
<inSequence>
<log description="Request Log" level="full"/>
<send>
<endpoint>
<http method="get" uri-template="http://localhost:8280/services/TestDataService.HTTPEndpoint/Member/{uri.var.MemberID}"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<datamapper config="gov:datamapper/MemberDetailsMapping.dmc" inputSchema="gov:datamapper/MemberDetailsMapping_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/MemberDetailsMapping_outputSchema.json" outputType="CSV"/>
<log description="Response Log" level="full"/>
<respond/>
</outSequence>
<faultSequence/>
</resource>
</api>
But still when I invoke the EI REST resource endpoint, http://localhost:8280/convertDetails/Member/0, it give me an ERROR.I have extracted the first few lines of the stack below.
[2018-11-01 10:30:30,817] [EI-Core] ERROR - DBInOutMessageReceiver Error in in-out message receiver
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:MemberID
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: TestDataService
Location: /Users/mad/Documents/wso2ei-6.3.0/wso2/tmp/carbonapps/-1234/1541088489969TestDataServiceProjectCompositeApplication_1.0.0.car/TestDataService_1.0.0/TestDataService-1.0.0.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getmember_memberid
Current Params: {}
I'm assuming that I have missed something along the configuration. Would appreciate your help regarding this.
We have created a proxy service in wso2 esb using esb poject in eclipse. This proxy service is invoking 2 web services, first one query data from legacy system and the other one creates sale order in oracle fusion.
This proxy service when run from soap ui executes successfully and creates sale order with no error. While when when run from scheduled task, it runs and creates order but gives error "Unexpected error sending message back {org.apache.synapse.core.axis2.Axis2Sender}" in wso2carbon.log file.
The xml for scheduled task is as follows
<task class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz" name="testtask2">
<trigger count="1" interval="60"/>
<property name="proxyName" value="EslSfaOFAOMSOIntegrationPS" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="soapAction" value="operation" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="injectTo" value="proxy" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="to"
value="http://10.1.6.176:8280/services/EslSfaOFAOMSOIntegrationPS.EslSfaOFAOMSOIntegrationPSHttpSoap11Endpoint" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="message" xmlns:task="http://www.wso2.org/products/wso2commons/tasks">
<soapenv:Envelope xmlns:esl="esl" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<esl:operation/>
</soapenv:Body>
</soapenv:Envelope>
</property>
</task>
The complete error log is as follows
TID: [-1234] [] [2017-02-23 06:19:17,471] ERROR {org.apache.synapse.core.axis2.Axis2Sender} - Connection:keep-alive,Content-Language:en,Content-Length:0,Content-Type:,Date:Thu, 23 Feb 2017 06:19:17 GMT,Server:Oracle-Application-Server-11g,Set-Cookie:<oracle fusion url>; httponly; secure; path=/,X-ORACLE-DMS-ECID:005IImNkZMq3z005RzH7id0001U70002LZ,<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope> Unexpected error sending message back {org.apache.synapse.core.axis2.Axis2Sender}
org.apache.axis2.AxisFault: Transport out has not been set
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:432)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:222)
at org.apache.synapse.mediators.builtin.RespondMediator.mediate(RespondMediator.java:35)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:260)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:766)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:282)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:261)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Put <property name="OUT_ONLY" value="true"/> inside your EslSfaOFAOMSOIntegrationPS proxy.
And I think you can remove to property since the message is sent to proxy given in proxyName property.
I'm using wso2dss 3.1.0 and wso2esb 4.7.0..I have created a restful dataservice in dss and it's working fine for all operations like get,post,update and delete.Now I wish to user this dataservice in esb..for this i have created a proxy with following configuration :
<target>
<endpoint>
<address uri="http://192.168.1.23:9764/services/A_resttest/"
format="soap11"/>
</endpoint>
<outSequence>
<send/>
</outSequence>
</target>
And tried to execute with curl command like this :
curl -v -H "Accept: application/json" http://youtility-desktop:8282/services/RestTest1
But it showing warning and error like :
WARN - SourceHandler Connection time out after request is read: http-incoming-1
ERROR - NativeWorkerPool Uncaught exception
java.lang.NullPointerException
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:156)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
WARN - SourceHandler Connection time out after request is read: http-incoming-2
I have referred https://docs.wso2.org/display/ESB460/Using+REST+with+a+Proxy+Service.
Is the procedure is correct or their is problem in curl command?Please let me know..I have tried this by creating api also but showing same error..Should i uncomment any code in axis2 file?
Are you going to expose the DSS service via SOAP using ESB? If not, I'd like to suggest that you create ESB REST API instead of a proxy service to expose the DSS service.
Secondly, you have set format="soap11" for the dss service endpoint. But as I understand from your question, you need to use rest format instead of soap 1.1. So, change the format to format="rest" or format="pox" depending on your requirement.
I have been given a REST URI from my client which is as follows:
https://vm3.digitary.net/verifier/HEDDRequestDocumentAccess
Following request xml has to be POSTed to the above URI to get the response xml.
<documentAccessRequest xmlns="http://www.digitary.net/schema/dare/hedd/documentAccessRequest/2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.digitary.net/schema/dare/hedd/documentAccessRequest/2013 http://www.digitary.net/schema/dare/hedd/documentAccessRequest/2013">
<head>
<institutionCode>BBCU</institutionCode>
<username>HEDDUser</username>
<password>HEDDPass</password>
</head>
<body>
<heddEnquiryId>12347895844</heddEnquiryId>
<enquiree>
<email>jane#doe.com</email>
<firstName>Jane</firstName>
<lastName>Doe</lastName>
</enquiree>
<enquirer>
<organisation>BBC</organisation>
<contactName>Jeremy Clarkson</contactName>
</enquirer>
<documentRequested>HEAR</documentRequested>
</body>
</documentAccessRequest>
Now I have the requirement to make my own wrapper REST API in WSO2 ESB 4.6.0 which would simply call the above mentioned REST URI having the same request and response XML. The idea is to make the pass through REST API to above mentioned API.
I have implemented the following REST API:
<api xmlns="http://ws.apache.org/ns/synapse" name="TestDareRest" context="/documentRequest" hostname="46.137.187.137" port="8280">
<resource methods="POST" url-mapping="/request/*">
<inSequence>
<log/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<send>
<endpoint>
<address uri="https://vm3.digitary.net/verifier/HEDDRequestDocumentAccess" format="pox"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log/>
<property name="ContentType" value="application/xhtml+xml" scope="axis2"/>
<send/>
</outSequence>
</resource>
</api>
But above API is not working at all and it is gving loads of errors in the esb console. I am using the SOAPUI to test this REST service and posting the same request xml from there. The service is deployed on our public Ip server and can be seen by login in to following
https://46.137.187.137:9443/carbon/admin/index.jsp with username/pwd as admin/admin
I have tried setting both media type in SOAPUI as text/xml and application/xml
In case of text/xml it is giving error as follows:
org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found documentAccessResponse
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:305)
In case of application/xml it is giving following error
INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:53a782ab-2081-4cb1-9e94-910b75816361, Direction: response
[2013-04-10 16:05:12,911] ERROR - PassThroughHttpSender Failed to submit the response
java.lang.UnsupportedOperationException
Please help me with this issue as it has got much critical to me.
Thanks in Advance
Shakshi
Can you switch the transport to nonblocking transport and check?
You can change the transport sender and receiver in the axis2.xml.
The media type is to be application/xml ..not the text/xml, which is used fro soap requests.
To post a request you can use curl utility.
# curl -X POST -d #request.xml "URL"
I am consuming an secured service hosted over basicHttpBinding
I have to pass credentials to the service for authenticatioon
Here’s the config setting for the client
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
While calling the service, I am getting following exception message
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
Message = "An invalid security token was provided (Bad UsernameToken Values)”
I not sure how to get it working I am curious if somebody can help me out or provide me any url where I could find the solution
When you create your MyServiceClient object you can set the username and password on the clientInstance.Credentials.UserName object.