WSO2 : "Error connecting to Back end" when testing Integration Solution - kubernetes

Hello everyone,
I deployed WSO2 APIM on a kubernetes cluster which includes the micro integrator, and I used Integration Studio locally to develop my first integration solution.
I followed these steps:
Configured the service catalog in Integration Studio using the ingress address of the APIM
The service appears inside the services tab
I created an API out of that service
Error : When I try testing the API I get the following error "Error Connecting to Back end"
I think the service url may be the problem, I tried using the ingress address for the Micro Integrator but it didn't work
The following is my configuration:
metadata.yaml file
---
key: "HelloWorld-1.0.0"
name : "HelloWorld"
displayName : "HelloWorld"
description: "Sample API"
version: "1.0.0"
serviceUrl: "https://localhost:8290/sample"
definitionType: "OAS3"
securityType: "BASIC"
mutualSSLEnabled: false
swagger.yaml file
openapi: 3.0.1
info:
title: HelloWorld
description: API Definition of HelloWorld
version: 1.0.0
servers:
- url: /sample
paths:
/testing:
get:
responses:
default:
description: Default response
and my API
<?xml version="1.0" encoding="UTF-8"?>
<api context="/sample" name="HelloWorld" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/testing">
<inSequence/>
<outSequence>
<payloadFactory description="name" media-type="json">
<format>
{"name":"$1","role":"$2"}
</format>
<args>
<arg evaluator="json" expression="$.name"/>
<arg evaluator="json" expression="$.role"/>
</args>
</payloadFactory>
</outSequence>
<faultSequence/>
</resource>
</api>
Hope Someone can help me as I'm really stuck

If you are trying to the testing through the console included in APIM, it might not recognize the Ingress host names (I assume the ingress host mapping is done in your local /etc/hosts). This should work if you use get the relevant curl and invoke it through the terminal.
As an alternative, you can use the service name (instead of Ingress host name) of the MI deployment and see whether you can invoke it through APIM's inbuilt console. This is of course if you have deployed those in the same namespace.

Related

keycloak provides different issuer for frontend and backend

I am new to keycloak, I am using keycloak for both frontend and backend application but I am getting the different issuer in the token generated by keycloak when decoded in jwt.io.
Front end:
the issuer is the same as the base URL of the frontend application
For example:
If the front-end URL is https://example.org/portal then the issuer is the same as https://example.org/auth
Request via postman:
the issuer is the internal DNS name
I have tried below ways,
Proxy redirection(With preserve host) - Which generates the issuer with frontend base url.
Proxy redirection without preserving host - Which expects the private DNS to be resolved at front end application
Played around the keycloak configuration - updated frontendUrl to https://example.org/auth and forceBackendUrlToFrontendUrl to true which resulted in the same issuer both the backend and frontend but no hostname like https:/auth/relam/external(Refer #2 in reference).
Expected outcome:
I need the private DNS to be issuer it both the request from frontend and backend(for now it works direct backend request)
Thanks in advance.
Reference
https://github.com/keycloak/keycloak-community/blob/master/design/hostname-default-provider.md
Code block
<spi name="hostname">
<default-provider>fixed</default-provider>
<provider name="fixed" enabled="true">
<properties>
<property name="frontendUrl" value="https://example.org/auth"/>
<property name="forceBackendUrlToFrontendUrl" value="true"/>
</properties>
</provider>
</spi>

WSO2 Data Service, Enterprise Integrator and Data Mapper mediator

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.

Expose RAML contract instead WADL in CXF

I am new in REST world, an in most of CXF examples that I saw there is an configuration to expose WADL in REST services when published.
Something like
Available RESTful services:
Endpoint address: http://localhost:8080/ouat-servicesImpl/api
WADL : http://localhost:8080/ouat-servicesImpl/api?_wadl
Then, when clicked
<application>
<grammars/>
<resources base="http://localhost:8080/ouat-servicesImpl/api">
<resource path="/topics">
<method name="POST">
<request>
<representation mediaType="application/json"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
</resource>
</resources>
</application>
I was learning RAML and its benefits in contract creation. Is there any way to expose RAML contract in this CXF "home" service page? Or am I mixing the concepts/ purpose of RAML and WADL? Actually I think both are ways to expose services contract, however in my opinion RAML is more complete
Assuming you package your CXF service as a WAR, here is how you can achieve your goal, based on a real project I'm working on:
Drop RAML and JSON files below the webroot folder: https://github.com/openanalytics/RPooli/tree/master/webapp/src/main/webapp/raml
Template baseUri so it can be injected at runtime: https://github.com/openanalytics/RPooli/blob/master/webapp/src/main/webapp/raml/api_v1.raml#L21
Declare .raml as if it's a JSP so injection can work: https://github.com/openanalytics/RPooli/blob/master/webapp/src/main/webapp/WEB-INF/web.xml#L70
Add the RAML mime-type: https://github.com/openanalytics/RPooli/blob/master/webapp/src/main/webapp/WEB-INF/web.xml#L76-L79
Add a filter to compute the dynamic part of the baseUri: https://github.com/openanalytics/RPooli/blob/master/webapp/src/main/java/eu/openanalytics/rpooli/web/BaseUriInjectionFilter.java
Wire it in web.xml: https://github.com/openanalytics/RPooli/blob/master/webapp/src/main/java/eu/openanalytics/rpooli/web/BaseUriInjectionFilter.java
Bonus point for:
Embedding the RAML API console: https://github.com/openanalytics/RPooli/tree/master/webapp/src/main/webapp/raml/ui
And redirecting to it from the web-app home page: https://github.com/openanalytics/RPooli/blob/master/webapp/src/main/webapp/index.html

Accessing restful services from wso2dss to wso2esb

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.

Create a REST proxy for SOAP service in wso2 esb

We have a SOAP service that I want to proxy in WSO2 ESB. This is for POC that I am working on. I came across various documents and some explanation on forums but nothing concrete yet. I looked at API option but couldn't get anything to work. Whats the best way to do this? Can the transformation occur in esb itself or is the api the only option? Please advise.
You can better choose RESTAPI option.
Here is the documentation for that
What do you mean by couldn't get this working? This is not a big configuration, you need to define your proxy service such that you send the message (REST message) to the back end as a SOAP message. Here is a sample configuration.
<proxy name="StockQuoteProxy" transports="http https" startOnLoad="true">
<target>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"
format="soap11"/>
</endpoint>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
You can call this proxy in REST manner and it will automatically send the message to the backend SOAP service.
you can do it with the sample axis2 client as below.
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy -Drest=true