Access WSO2 Data Services Service via WSO2 ESB - wso2

I have created a service (Products) which accepts a ProductID value and returns data. I have SOAP and HTTP requests and responses for this service. I can access this by doing something like h**p://localhost:9763/services/Products.HTTPEndpoint/ProductID/123456 to return data.
How can I do the same thing but go through the ESB? I've tried to set up a simple pass through proxy, but when I use the "TryIt" I only get "mediate" as a option.
Any ideas?
Thanks,
Jared

You should use an appropriate WDSDL as the publish WSDL of the proxy service to 'tryit' the proxy service.
So what you can do is, get the WSDL of the actual data service and use that as the publish wsdl of the proxy. Then you can use tryit to invoke the DS.

I ended up being able to do this:
WSO2 Data Services Server service:
http://localhost:9763/services/Products
WSO2 ESB Endpoint:
Name: epProducts
Address: http://localhost:9763/services/Products.HTTPEndpoint
Format: GET
WSO2 ESB Proxy Service:
Service Name: ProductsProxy
Publishing WSDL: None
Define In Sequence: None
Define Endpoint: epProducts
Define Out Sequence: None
Define Fault Sequence: None
Send a GET request to:
http://localhost:9763/services/Products.HTTPEndpoint/ProductID/123456

Related

Why do Data Services use the Servlet Ports as opposed to NIO/PT - WSO2

I've installed Dss 3.2.2 features onto Esb4.8.1.
When I create a proxy service the Service endpoints are as expected e.g
http://[ip]:8280/services/[proxy_service_name]
But when I create a dataservice , the service endpoints also show the same(NIO) port , contrary to the expected (mgmt) port :
http://[ip]:8280/services/[data_service_name]
But it should be
http://[ip]:9763/services/[data_service_name]
If I send a json post request to the 8280 for a dataservice , it does not receive any params :
"current_params": "{}"
Sending it to 9763 it reads my params:
"current_params": "{no=xxx, dump_size=10}"
Is there a config/way to fix this?
I believe you are using try-it tool shipped with WSO2 ESB by default. Let me explain what it the reason for this problem. WSO2 ESB exposes two HTTP ports (i.e NIO port which is 8280 and servlet port which is 9763) and when dataservice features are installed, data services are also exposed via both ports. By default ESB try-it uses NIO port(8280). The issue is ESB try-it tool does not handle invoking data service via NIO transport. It drops the parameters passed. That is why the current_params is empty. This is a known issue and will be fixed in a future release. As a workaround you can either use servlet port to invoke dataservice or any other soap client such as SoapUI.
Thanks

Not able to invoke axis2 service from wso2 ESB proxy service

I am new to OSB.
-> I have a AXIS2 webservice application running on wso2 appserver. If we pass a name as a parameter it will return hello + Name.
-> I am trying to access this application from proxyservice in WSO2 ESB application.
The project name is SampleESBConfig and proxy service name: ESBtoAxis2PS1
Steps for Implementing proxy service:
The proxy service ha wsdl url : http://localhost:9763/services/Test1?wsdl ; Wsdl Type: SOURCE_URL
InFlow
Placed LogMediator
place SendMediator
Created address endpoint which points to : http://localhost:9763/services/Test1 [ Target URL, AXIS2 webservice application URL]
OutFlow
Placed LogMediator
place SendMediator
Fault Sequence
Placed the LogMediator
Created Composite application which includes the above proxyservice
Deployed this application on WSO2 ESB server which is running on localhost.
Note:
Both ESB & appserver running on localhost
When i am trying to test the application getting the below error.
[2015-06-18 16:27:55,212] ERROR - Axis2Sender Unexpected error during
sending message out org.apache.axis2.AxisFault: The system cannot
infer the transport information from the
/services/ESBtoAxis2PS1.ESBtoAxis2PS1HttpSoap11Endpoint URL.
How do I fix this?
Let assume that your are calling the echo proxy and you are creating a soap project by providing the wsdl of your proxy service.Then the request url for echo service will be
http://localhost:8280/services/echo.echoHttpSoap11Endpoint and when you are going to invoke it, you will get the above error.
As a solution for it you need to remove the part behind the "." operator. So you proxy calling url will be http://localhost:8280/services/echo
According to the error log I found that you are calling the proxy service /services/ESBtoAxis2PS1.ESBtoAxis2PS1HttpSoap11Endpoint . So you need to call the proxy like /services/ESBtoAxis2PS1 as I mentioned earlier.
Hope this may solve the issue.

How to create data service with local transport using proxy?

I have created data service using WSO2 DSS which is called by proxy service.
Everything works smoothly, but this DSS service is also visible to internet.
Now I would like to hide this DSS so proxy service is so only way to use this service.
Proxy has security, logging etc.
As far as I understand local transport is good and efficient way to keep
traffic between services internal on WSO2.
Everything goes as expected but when I try to set WSDL URL or internal for proxy (which is DSS service WDSL) I get error "Unable to modify proxy service :: Unable to modify proxy service: mylogtest-ProxyServiceAdminProxyAdminException".
In log file there is error "Caused by: org.apache.synapse.SynapseException: Error building service from WSDL" and "Caused by: org.apache.axis2.AxisFault: there is no service with ports to pick".
I get this error when I have local transport only in DSS.
If I add http transport, everything works. Proxy has http and https transports.
Local transport works only inside a single JVM. I guess here you are running DSS and ESB separately i.e. with two jvm instances - if so it won't work. The solution is to install DSS features inside the ESB and then run it (without running the DSS separately). You can find the feature installation guide here: http://docs.wso2.org/display/Carbon420/Installing+Features+via+the+UI
I had incorrectly formed WSDL for proxy. Very novice error.

WSO2 ESB how to securize a proxy by default when deploy

I have a lot of proxies in WSO2 ESB that I have to securize. I need them to be securized using Username Token when deploy, instead of browsing to the dashboard and enabling it one by one.
Any help?
I guess currently, you need to use management console and do it. From the UI, it is calling a backend web service. You can automate process by automating this backend web service. This web service is exposed by following component [1]. You can use soapui or some client program to automate this web service.
[1] http://svn.wso2.org/repos/wso2/carbon/platform/trunk/components/security/org.wso2.carbon.security.mgt/
I had similar requirement, here is how I solved it
Apply Role security to WSO2 ESB Proxy using Java API
Also you can find the test case here on how to use the methods
http://svn.wso2.org/repos/wso2/tags/carbon/3.2.3/products/bps/2.1.1/modules/integration/org.wso2.bps.management.test/src/test/java/org/wso2/bps/management/SecurityTest.java
Well here how the code snippet goes to secure any proxy service with default security scenarios of WSO2 ESB. In WSO2 ESB "scenario1" signifies Usernametoken based security. Now if you wish to secure your proxy with scenario1 follow the below code snippet:
public void applySecurityOnService(String serviceName, String policyId,
String[] userGroups, String[] trustedKeyStoreArray,
String privateStore)
throws SecurityAdminServiceSecurityConfigExceptionException,
RemoteException {
ApplySecurity applySecurity;
applySecurity = new ApplySecurity();
applySecurity.setServiceName(serviceName);
applySecurity.setPolicyId("scenario" + policyId); //scenario1 i.e. for Usernametoken security policyId should be 1
applySecurity.setTrustedStores(trustedKeyStoreArray);
applySecurity.setPrivateStore(privateStore);
applySecurity.setUserGroupNames(userGroups);
stub.applySecurity(applySecurity);
_logger.info("Security Applied Successfully");
}
Here is how you may call this method from your client class:
applySecurityOnService("MyProxy", "1", new String[]{"TestRole"}, new String[]{"wso2carbon.jks"}, "wso2carbon.jks");

Custom Uri or endpoint on WSO2

We have just installed our WSO2 ESB, and we are trying to create some proxies services with customs endpoints.
The default endoint format is:
http://{host}:{port}/services/{Proxy Service Name}
I'd like to have something like:
http://{host}:{port}/services/utilities/{Proxy Service Name}
http://{host}:{port}/services/public/{Proxy Service Name}
I followed this tutorial:
http://wso2.org/library/knowledge-base/2011/01/custom-urls-wso2-esb-proxy-services
but we have a problem, when I send a request to my custom endpoint, I have no answer.
suggestions?
I assume that you were able to properly create a custom endpoint and "I have no answer" means you didn't get any response. If it is the case following are the possible reasons for that,
Proxy service endpoint didn't receive the request
Proxy service didn't configured properly to response back
So test whether the 1 is the reason you can simply put a log mediator with following configuration in inSequence,
<log level="full"/>
then if the proxy service received a message it will log it in console. If that works could you please post your proxy service configuration to check whether it is properly defined.
Well, it seems that we've found a solution, I'm going to resume the full solution.
As the tutorial indicates, to costumize your proxy service endpoint, you have to add the following handler on the axis2.xml configuration:
<handler name="CustomURIBasedDispatcher" class="org.apache.synapse.core.axis2.CustomURIBasedDispatcher"/>
Then, you can customize your endpoint on the design view or on the source view, I've choosen the source view, adding this parameter:
<parameter name="ServiceURI">/services/intern</parameter>
The custom endpoint is autogenerated as:
http://{host}:{port}/services/intern.myWebservice
But I has not worked for me. If I send a request to the custom endpoint, I have no response.
I've solved the problem, adding to the "ServiceURI" parameter the name of the service:
<parameter name="ServiceURI">/services/intern/myWebService</parameter>
then you have to send the request to the following endpoint:
http://{host}:{port}/services/intern/myWebService
So now you have a custom endpoint for every proxy service.
Thanks Malith for your help.