I have this simple example of my rest api, and now I want to add https capabilities to this resource.
<api name="API_FEETIT_VERSION" context="/api_feetit_version">
<resource methods="GET" protocol="https">
<inSequence>
<send>
<endpoint>
<address uri="http://myserver.net/version"/>
</endpoint>
</send>
</inSequence>
</resource>
To do this I just added attribute protocol="https" on resource, but now I cant access the service. Already try on port 8243 but still nothing.
Do I need to do anything else? Or even my endpoint service needs to use https too?
Yes , your backend service will need to be https as well as your endpoint address.
<address uri="https://myserver.net/version"/>
Log in to the ESB Management console.
Under "Service Bus" section/tab , click the last option "Source View".
Search(ctrl-f) for you API , then its resource , and check if protocol="https". This is one of mine:
< resource methods="POST"
protocol="https"
inSequence="ackServiceSeq"
outSequence="hcfRequest"/ >
Weird how the "invokation url" stays the same
Related
I want to use WSO2EI 6.4.0 as a proxy for SOAP and REST services authentication platform (later maybe authorization).
I found solution in documentation of wso2 (https://docs.wso2.com/display/EI640/Applying+Security+to+an+API), but unfortunately it is not working.
Adding "handler" element into service definition
<handlers>
<handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>
</handlers>
results into exception in design time (eclipse):
Invalid mediator <handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/> 1d6bbce1-08e3-42d5-b550-6a4e224b0028.xml /.tmp/.org.wso2.developerstudio.eclipse.esb line 15 org.wso2.developerstudio.eclipse.gmf.esb.diagram.synapseerror
Ignoring and deploying such API, makes the API stop working.
Could anyone help please?
The way you are trying to add the Basic authentication for API in WSO2EI 6.4.0 is correct. Developer studio will give a warning as you mentioned, but it should not be an issue. Developer studio will allow setting the handler regardless of the warning and you should be able to create a Composite Application which includes the API and deploy it to ESB. Following is a sample API with the RESTBasicAuthHandler.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/testapi" name="testapi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" protocol="https" url-mapping="/*">
<inSequence>
<send>
<endpoint name="testapi_EP">
<http uri-template="http://localhost:8080/testapi"/>
</endpoint>
</send>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
<handlers>
<handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>
</handlers>
</api>
I need to add api service using wso2 api management or wso2 ei. i have a web api with ip:port format that have response via postman but when i add web api in api manager or wso2 ei in api menu and call published api via postman i get this error
method not allowed and in log i have this error : main sequence executed for call to non-existent = /CardTransfer/
my API Source :
<api xmlns="http://ws.apache.org/ns/synapse" name="NoorService" context="/CardTransfer" version="v1" version-type="url">
<resource methods="POST">
<inSequence>
<log level="full">
<property name="befor" value="befor"/>
</log>
<send>
<endpoint>
<http uri-template="http://x.x.x.x:9110/"/>
</endpoint>
</send>
<log level="full">
<property name="after" value="after"/>
</log>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
The request URL for the API resource you have created is:
https://<ip>:<port>/CardTransfer
the forward slash end of the API context should be omitted.
If the API resource contains a url-mapping="/", the request URL would be:
https://<ip>:<port>/CardTransfer/
I'm trying to call a web service in tomcat through api resource in WSO2 ESB.
The resource is:
<resource methods="DELETE" url-mapping="/weight/delete">
<inSequence>
<log level="custom">
<property name="Access token value" expression="$trp:Authorization"/>
</log>
<oauthService remoteServiceUrl="https://host:port/services/" username="username" password="password"></oauthService>
<header name="Authorization" scope="transport" action="remove"></header>
<send>
<endpoint>
<address uri="http://host:8080/web-services/services/proyect1"></address>
</endpoint>
</send>
</inSequence>
It hasn't query params and path params.
But I have an 500 internal server error, and tomcat throw this exception:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
The request is:
Method: Delete
http://host:8282/web-services/services/proyect1/weight/delete
Head: Authorization: Bearer 89712389712hd97861h
Payload: [{"id":"307"}]
All is correct sending request directly to tomcat.
According to REST, delete method in HTTP must not content payload. Then, http://host:8282/web-services/services/proyect1/weight/delete it's not correct.
But, to resolve this problem I can use a PayLoadFactory mediator in WSO2 to send JSON to endpoint.
Iteration mediator works with WSo2 Tryit tool but when the same message is sent through SOAP UI the proxy it does not iterate. My proxy service is very simple it has a xslt mediator and then does the iteration. Do I need to change the content type?
Can you paster your proxy service source code.
Try it tool is a evolving tool, but you should always do your testing from SOAP UI.
This is the sample format :-
<iterate expression="//m0:getQuote/m0:request" preservePayload="true"
attachPath="//m0:getQuote"
xmlns:m0="http://services.samples">
<target>
<sequence>
<send>
<endpoint>
<address
uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</sequence>
</target>
how to use faultsequence of proxy in esb
i want to use faultsequence when occur a fault in EndPoint. for example i stop service1 using jconsole and want to route message to service2 when call proxy service. but when i call proxy using soapui it show fault this message : The system is attempting to access an inactive service..
<target>
<inSequence >
<send>
<endpoint name="cal" >
<address uri="http://localhost:9763/services/service1/"/>
</endpoint>
</send>
</inSequence>
<faultSequence>
<log level="custom">
<property name="text" value="An unexpected error occured for service"/>
<property name="message" expression="get-property('ERROR_MESSAGE')"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9763/services/service2/"/>
</endpoint>
</send>
</faultSequence>
please guide me!
When your endpoint 1 is inactive it returns a soap fault and you want it to go to the fault sequence. But at the moment that fault sequence is considered as a response and it is sent to the client (soap ui).
In WSO2 ESB 4.5.0 onwards, there is a new property FORCE_ERROR_ON_SOAP_FAULT added. By setting this property, soap faults will be directed to fault sequence. You can do your next logics when you are in the fault sequence (for example invoking another sequence).
Refer [1] for a sample proxy service.
[1] http://maharachchi.blogspot.com/2012/09/now-you-can-send-soapfaults-to-fault.html
I believe your exact scenario is apart of your main end point if it faild you need to route the message to secondary endpoint.
Correct approach to your implementation is not using the fault sequence right approach is using fail over endpoint. You can find reference document at [1][2].
For sample you can refer "Sample 53: Failover sending among 3 endpoints" [3].
[1].http://wso2.org/project/esb/java/3.0.1/docs/endpoint_guide.html#FoEp
[2].http://docs.wso2.org/wiki/display/ESB403/Failover+Endpoint
[3].http://wso2.org/project/esb/java/3.0.1/docs/samples/endpoint_mediation_samples.html
Thank You,
Dharshana.