Publishing API's in WSO2 ESB using WSO2 API Manager - wso2

I can't publish API's in WSO2 ESB from WSO2 API Manager. My legacy architecture has two WSO2 ESB instances, first ESB is only a Gateway component, and second ESB works conventionally.
Now, I need to use an API Manager instances to publish API's in the ESB's intances.
But, I configure APIGateway section in /repository/conf/api-manager.xml to point to ESB instance, like this:
<APIGateway>
<Environments>
<Environment type="production" api-console="true">
<Name>Production and Sandbox</Name>
<Description> Description of environment</Description>
<!--ServerURL>https://${carbon.local.ip}:${mgt.transport.https.port}${carbon.context}/services/</ServerURL-->
<ServerURL>https://localhost:8243/services/</ServerURL>
<!--Username>${admin.username}</Username-->
<Username>admin</Username>
<!--Password>${admin.password}</Password-->
<Password>admin</Password>
<!--GatewayEndpoint>http://${carbon.local.ip}:${http.nio.port},https://${carbon.local.ip}:${https.nio.port}</GatewayEndpoint-->
<GatewayEndpoint>http://localhost:8280,https://localhost:8243</GatewayEndpoint>
</Environment>
</Environments>
<EnableGatewayKeyCache>true</EnableGatewayKeyCache>
<EnableGatewayResourceCache>true</EnableGatewayResourceCache>
<ClientDomainHeader>referer</ClientDomainHeader>
</APIGateway>
And, in I tired to point to 8243 port as well, and I couldn't publish in ESB instance.
In logs, I can see following:
2016-05-05 08:33:29,551 [-] [http-nio-9443-exec-42] INFO LogMediator To: https://localhost:9443/services/APIGatewayAdmin, From: 127.0.0.1, WSAction: urn:getApi, SOAPAction: urn:getApi, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns2:getApi xmlns:ns2="http://service.gateway.apimgt.carbon.wso2.org"><ns2:apiProviderName>admin</ns2:apiProviderName><ns2:apiName>name</ns2:apiName><ns2:version>1.0</ns2:version></ns2:getApi></soapenv:Body></soapenv:Envelope>
So, API Manager tries publish in ESB, and ESB recives request but I get only one error in logs a few lines below:
2016-05-05 08:33:55,865 [-] [http-nio-9443-exec-4] DEBUG AxisServlet
java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:123)
at org.apache.axis2.transport.http.AxisServlet.createMessageContext(AxisServlet.java:715)
[...]
2016-05-05 08:33:55,867 [-] [http-nio-9443-exec-4] DEBUG Options getAction (null) from org.apache.axis2.client.Options#353f3a03
Do I need to configure the ESB to do this?

Related

Exception - WSO2

Getting an exception while running the example given at
http://wso2.com/library/articles/2012/10/implementing-restful-services-wso2-esb/
ESB version :- 4.8.1
DSS version :- 3.2.1
[2015-02-03 15:51:12,063] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:3e75d7db-d23c-4f2c-821a-c2e9ae3faa25, Direction: response, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.x
mlsoap.org/soap/envelope/"><soapenv:Body><faultstring>The endpoint reference (EPR) for the Operation not found is /services/StudentService/003/GetStudent?registration_number=003 and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.</faultstring></s
oapenv:Body></soapenv:Envelope>
please suggest how to run this example.
Try How to GET a Cup of Coffee the WSO2 Way
tutorial which has comprehensive explanation for implementing RESTful service using WSO2 products (WSO2 ESB and WSO2 AS).

WSO2 ESB Proxy to WSO2 IS RemoteUserStoreManagerService

I want to proxy RemoteUserStoreManagerService (exposed on WSO2 IS) over WSO2 ESB.
When I call getUserClaimValuesForClaims operation I get the response. I tested the WSO2 IS (connected to my Active Directory) for performance. I sent requests in 100 threads (each thread with 250ms delay) and it gave me an average response of 250ms (which is ok for me).
So I proxied the getUserClaimValuesForClaims operation using the Transformation proxy and it also worked. But during the performace testing (with the same or smaller load) I have got following errors and not all the messages have returned (on average 1 of 100 messages).
[2014-01-06 19:28:21,047] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:d2b85c03-beaf-409b-bf39-2e8143bd9e0b, Direction: response
[2014-01-06 19:28:38,441] ERROR - SourceHandler I/O error: An established connection was aborted by the software in your host machine
java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:202)
at sun.nio.ch.IOUtil.read(IOUtil.java:175)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:243)
at org.apache.http.nio.reactor.ssl.SSLIOSession.receiveEncryptedData(SSLIOSession.java:348)
at org.apache.http.nio.reactor.ssl.SSLIOSession.isAppInputReady(SSLIOSession.java:376)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady
[2014-01-06 19:29:14,051] WARN - TargetHandler http-outgoing-66: Connection time out while in state: REQUEST_DONE
[2014-01-06 19:29:14,061] WARN - EndpointContext Endpoint : AnonymousEndpoint will be marked SUSPENDED as it failed
[2014-01-06 19:29:15,041] WARN - EndpointContext Suspending endpoint : AnonymousEndpoint - last suspend duration was : 30000ms and current suspend duration is : 30000ms - Next retry after : Mon
[2014-01-06 19:29:14,451] WARN - SourceHandler Connection time out after request is read: http-incoming-57
I thing that it says, it timeouts on backend; but I get the response logged in faultSeuence.
I noticed that the problem is caused by the XSLT mediator in proxy implementation, because when I removed the xslt mediators the log is empty. I tried xquery and it was the same. Even the log mediator in outSequence causes this issues.
Here is my final Proxy.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="GetUserProxy" transports="https http" startOnLoad="true" trace="disable">
<target>
<endpoint>
<address uri="https://localhost:9443/services/RemoteUserStoreManagerService.RemoteUserStoreManagerServiceHttpsSoap12Endpoint/"/>
</endpoint>
<inSequence/>
<outSequence>
<log/>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
When I remove the log mediator, the WARN messages disapears from log and ALL response messages are returned to SoapUI.
Could anybody tell me why it behaves this way?
Thank you very much.
David
RemoteUserStoreManagerService is an admin service. Therefore, you need to send Identity Server's user name/password in a basic authentication header or session cookie. I can not see setting of authorization headers in your proxy configuration such as following
<property expression="fn:concat('Basic ', base64Encode('username:password'))" name="Authorization" scope="transport"></property>
More details would be here. Also you need to create a message body to send to the "RemoteUserStoreManagerService" and read the response messages. These must be implemented using ESB configuration. However, you can write an custom ESB mediator to do this also. Sample java code to call this service can be found here. You can find the detail on writing custom mediator from here
We have figured out, that the problem is probably more general and doesn't relate only to WSO2 IS, because we have the same problem when similating the WSO2 IS service as SoapUI mock.
The problem is probably in HTTP-passthru transport in axis configuration, because when we switched to HTTP-NIO the problem disapears and it is even faster.
There is a post about performance tunnig that helped us.
Howevever, I would like to know what transport we should use in production or where the problem is. Because now it seems that we cannot use HTTP-passthru transport for production environment.
Is anyone experiencing this problem?
what are the versions of ESB and IS your working with..?
try to restart the ESB and call the Service again. Do remember call to Identity server is a secure call.

How to deploy an API in WSO2 ESB referring to 3 endpoint services in WSO2 DSS

Trying to deploy an API which can gather response from multiple services (endpoints) in DSS (Application Server) and combine the responses in ESB.
Consider API as "Person" it has a GET method "getperson"
"getperson" -- accepts personID as the parameter (query filter).
RESPONSE:
<person>
<id\>
<name\>
<type\>
<address>
<street\>
<apt\>
<city\>
<state\>
<zipcode\>
</address>
<image>
<id\>
<description\>
<title\>
</image>
<person>
services in DSS are as follows ::
person_service
RESPONSE:
<person>
<id\>
<name\>
<type\>
<addressid\>
<imageid\>
</person>
2. address_service
RESPONSE:
<address>
<street\>
<apt\>
<city\>
<state\>
<zipcode\>
</address>
3. image_service
RESPONSE:
<image>
<id>
<description>
<title>
</image>
I was able to create services successfully in DSS. But unable deploy an API using all the 3 service endpoints into one API GET method call.
I was following the sample given in the documentation for service chaining http://docs.wso2.org/display/ESB460/Service+Chaining
But, in that sample it was done using proxy service. I am not sure how to connect that to API's
ESB version: 4.6.0
DSS version: 4.0.1
Thank you
You can do the same service chaining logic in API. If you look at API configuration, where you can define mediation logic as InSequence and OutSequence like you do for proxy service.
At the same time, you can define a proxy service with same logic, and provide that proxy service as your endpoint for your API.

wso2: ws-discovery integration

WSO2 WS-Discovery Integration
We're trying to integrate WS-Discovery with the Carbon products WSO2 Governance Registry and WSO2 ESB having
Apache CXF Web Service stack configured via Spring running on a Tomcat sending hello messages to the
Discovery Proxy (localhost:9443/services/DiscoveryProxy) on WSO2 Greg.
Therefore we added cxf-services-ws-discovery-service.jar and cxf-services-ws-discovery-api.jar to the
classpath in Tomcat. Further we set the spring bus property org.apache.cxf.service.ws-discovery.address
to the URL address of the WS-Discovery Proxy on WSO2 Greg to run WS-Discovery in managed mode. By running
Tomcat and WSO2 Greg following error messages is logged in wso2Carbon.log (WSO2 Greg) ...
TID: [0] [Greg] [2013-07-15 11:45:03,411] INFO {org.wso2.carbon.discovery.proxy.DiscoveryProxy} - Service Discovery Failed. Retrying after 10s. {org.wso2.carbon.discovery.proxy.DiscoveryProxy}
TID: [0] [Greg] [2013-07-15 11:45:03,458] ERROR {org.wso2.carbon.governance.api.common.GovernanceArtifactManager} - Failed to add artifact: artifact id: urn:uuid:003aa9d9-2c9f-4e0b-8415-c99632226ee3, path: /trunk/services/org/oasis_open/docs/ws_dd/ns/discovery/_2009/_01/DiscoveredService_1373881503442. An exception occurred while executing handler chain. String index out of range: -1 {org.wso2.carbon.governance.api.common.GovernanceArtifactManager}
org.wso2.carbon.registry.core.exceptions.RegistryException: An exception occurred while executing handler chain. String index out of range: -1
at org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager.put(HandlerManager.java:2525)
at org.wso2.carbon.registry.core.jdbc.handlers.HandlerLifecycleManager.put(HandlerLifecycleManager.java:1005)
at org.wso2.carbon.registry.core.jdbc.EmbeddedRegistry.put(EmbeddedRegistry.java:697)
at org.wso2.carbon.registry.core.caching.CacheBackedRegistry.put(CacheBackedRegistry.java:465)
at org.wso2.carbon.registry.core.session.UserRegistry.put(UserRegistry.java:658)
at org.wso2.carbon.governance.api.common.GovernanceArtifactManager.addGovernanceArtifact(GovernanceArtifactManager.java:155)
at org.wso2.carbon.governance.api.services.ServiceManager.addService(ServiceManager.java:116)
at org.wso2.carbon.discovery.util.DiscoveryServiceUtils.addService(DiscoveryServiceUtils.java:152)
at org.wso2.carbon.discovery.proxy.DiscoveryProxy$1.run(DiscoveryProxy.java:89)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1911)
at org.wso2.carbon.registry.extensions.handlers.utils.EndpointUtils.deriveEndpointFromUrl(EndpointUtils.java:674)
at org.wso2.carbon.registry.extensions.handlers.utils.EndpointUtils.saveEndpoint(EndpointUtils.java:483)
at org.wso2.carbon.registry.extensions.handlers.utils.EndpointUtils.saveEndpointsFromServices(EndpointUtils.java:280)
at org.wso2.carbon.registry.extensions.handlers.ServiceMediaTypeHandler.put(ServiceMediaTypeHandler.java:353)
at org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager.put(HandlerManager.java:2503)
... 14 more
We tried to solve this issue for several hours by reading WSO2 product documentation and searching through
several forums, blogs etc. . Unfortunely we couldn't find a solution.
Remark: WS-Discovery integration with WSO2 Application Server instead of Tomcat just worked fine.
But when using WSO2 ESB as an discovery client to discover services from WSO2 Greg the wizard to create proxy services out of the
discoverd services on WSO2 ESB is missing the publishWSDL xml tag after creating the proxy. This tag must be added
manually. Is there a way to get this done without editing this additionally??
We would be grateful for any help.
Thanks in advance
Thank you for your quick reply
We intercepted the hello requests sent to WSO2 GReg via Tomcat and the WSO2 Application server. For this purpose we used soapUI mock
services. The message requests of the soap envelopes look as follows ...
Tomcat:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:tns="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01">
<soap:Header>
<wsa:Action>http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Hello</wsa:Action>
<wsa:MessageID>urn:uuid:e01ce7dc-53c0-4b36-b7d5-0e84e3bd6a5d</wsa:MessageID>
<wsa:To>https://localhost:9443/services/DiscoveryProxy</wsa:To>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/none</wsa:Address>
</wsa:ReplyTo>
</soap:Header>
<soap:Body>
<ns2:Hello xmlns="http://www.w3.org/2005/08/addressing" xmlns:ns2="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01">
<EndpointReference>
<Address>urn:uuid:be46c1fc-1646-4bcc-8715-1aed4040fdd5</Address>
<ReferenceParameters/>
</EndpointReference>
<ns2:Types xmlns:ns3="http://user.service.scheck.server.tia/">ns3:IZ3UserService</ns2:Types>
<ns2:Scopes/>
<ns2:XAddrs>/userService</ns2:XAddrs>
<ns2:MetadataVersion>1</ns2:MetadataVersion>
</ns2:Hello>
</soap:Body>
</soap:Envelope>
WSO2 Application Server:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<mns:serviceName xmlns:mns="http://www.wso2.org/ws/discovery">echo</mns:serviceName>
<mns:wsdlURI xmlns:mns="http://www.wso2.org/ws/discovery">http://10.200.2.114:9764/services/echo?wsdl</mns:wsdlURI>
<wsa:To>https://localhost:9443/services/DiscoveryProxy</wsa:To>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/none</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>urn:uuid:d21e108b-34a2-4313-8b12-a22015567a51</wsa:MessageID>
<wsa:Action>http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Hello</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<wsd:Hello xmlns:wsd="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01">
<wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Address>urn:uuid:439a1cd5-fb36-40e2-a54e-e0cb7f3409e4</wsa:Address>
</wsa:EndpointReference>
<wsd:Types xmlns:axis2ns1="http://echo.services.core.carbon.wso2.org">axis2ns1:echoPortType</wsd:Types>
<wsd:Scopes>http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/DefaultScope</wsd:Scopes>
<wsd:XAddrs>https://10.200.2.114:9444/services/echo http://10.200.2.114:9764/services/echo</wsd:XAddrs>
<wsd:MetadataVersion>1</wsd:MetadataVersion>
</wsd:Hello>
</soapenv:Body>
</soapenv:Envelope>
Comparing both message requests we noticed that there are some tags missing like serviceName, wsdlURI and most important
in our opinion the XAddrs. By adding the XAddrs manually to an soapUI request we were able to register the cxf service
on WSO2 GReg. Maybe you can give us an advice how this could be achieved by configuring cxf via spring or by annotating our
web service implementations.
Thanks again..this helped us very much!!

WSO2 API Manager service API call failure while loading throttling policy

Currently we are trying to expose our Axis2 web services via WSO2 API manager. However in some cases service do not return result and looking at logs on WSO2 API manager we see the following
ERROR {org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler} - Unable to load throttling policy using key: gov:/apimgt/applicationdata/tiers.xml {org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler} TID: [0] [AM] [2013-01-07 16:42:22,951]
INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: /TestService/1.0.0, WSAction: urn:testOperation, SOAPAction: urn:testOperation, MessageID: urn:uuid:a8f94f58-5e2d-4d51-afc7-83182b51d173, Direction: request, STATUS = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Unable to load throttling policy using key: gov:/apimgt/applicationdata/tiers.xml, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><p:testOperation xmlns:p="http://example.com"><param>d1</param></p:testOperation></soapenv:Body></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
For configuration i use the default h2 database as registry and mysql database for user and api manager database.
This issue is a known issue [1],which will be fixed in the next AM release. We also encountered this issue at a instance,when we are trying invoking two different APIs at same time or within short time period.
Thanks;
[1] https://wso2.org/jira/browse/APIMANAGER-835