Set javax.net.ssl.trustStore from inside an Axis2 web service - web-services

I coded a web service A which call another web service B located in https://servername:9443/services/AuthenticationAdmin.
To validate the server certificate I set the truststore:
System.setProperty("javax.net.ssl.trustStore", "/home/wso2/wso2/bin/wso2bam-2.5.0/repository/resources/security/wso2carbon.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
As you can see I've tried to reference the truststore located in the filesystem of the host where my web service A is deployed. But when the web service B is invoked (from ny web service A) I receive the following error:
<soapenv:Reason xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Text xml:lang="en-US">Connection has been shutdown: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty</soapenv:Text>
</soapenv:Reason>
Afterwards I've tried to put the truststore file inside the .aar file and I referenced it as follow:
System.setProperty("javax.net.ssl.trustStore", "/wso2carbon.jks");
and even
System.setProperty("javax.net.ssl.trustStore", "wso2carbon.jks");
but no success.
How can I set the truststore from inside an Axis2 web service?
Thanks in advance.

This means the path is not correct or the wso2carbon.jks file does not have read permission.
You can find a sample on how trustStore is set in [1]. See class ServiceInvoker
[1] - http://hi-my-world.blogspot.com/2014/04/how-to-write-client-to-invoke-wso2.html

Related

Create a Proxy by Command Prompt (SSL Certificate)

I have a web service(asmx) and it has a certificate for SSL. I can access this web service and see whole methods. I want to create a proxy by command prompt and I am using below code.
wsdl MyServiceAdres?wsdl
and this is the error message:
There was an error downloading 'MyServiceAdres?wsdl'.
The request was aborted: Could not create SSL/TLS secure channel.
I solved this problem. You have to save wsdl file to your local and use below code.
wsdl.exe myWebService.wsdl myXsd1.xsd myType1.xsd myXsd2.xsd ...

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.

Configuring WSDL Based Proxy in WSO2 version 4.6

I have down loaded WSO2 ESB Version 4.6 and started the server. Clicked on proxy service. There I have selected WSDL Proxy option. It is asking the following for creating proxy.
Proxy Service Name* OpportunityService
WSDL URI* https://crm-aufsn4x0ruf.oracleoutsourcing.com//opptyMgmtOpportunities/OpportunityService?WSDL
WSDL Service* https://crm-aufsn4x0ruf.oracleoutsourcing.com:443/opptyMgmtOpportunities/OpportunityService
WSDL Port* 443
I just want consume this external web service via ESB. So I dont want publish. Did not configure any publish related fields. Now When I click on create it throws exception "Failed to add proxy service: OpportunityService. Check whether the Proxy already exists
". But I am sure that there is no existed service with that. I have tried with different names but the error is same.
I suspect that may gave values wrong for fields WSDL Service and WSDL Port. If click on Test URI its giving success.Can any one please suggest where I am doing wrong.
Thanks&Regards,
Raghu
For wsdl service parameter you need to give the <wsdl:service name>which you can find in the particular wsdl itself. I dont think it will be a URI like you have mentioned above. Likewise for port you can find the <wsdl:port> parameter in the wsdl.

How to run an ssl EJB Webservice?

I have created an Ejb endpoint WebService (.EAR) using metro and glassfish 3.1.2(b5) .
The wsdl file is published and accessible via https .
I generated the client artifact from the secured url and when I Run the client I get this error (server side):
ATTENTION: Invalid request scheme for Endpoint my_web_service. Expected https . Received http
This how I configured the secure connexion:
<glassfish-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>my_web_service</ejb-name>
<webservice-endpoint>
<port-component-name>my_web_service</port-component-name>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</webservice-endpoint>
</ejb>
</enterprise-beans>
</glassfish-ejb-jar>
If I change the implementation to a servlet endpoint (.war) everything run ok so I think that I'm missing something in the configuration.
To make this work you need to update the bundled version of grizzly in glassfish to 1.9.55 .

jaxws client get https wsdl errors

I am testing a web service hosted on https. I use jaxws for the connection.
This retrieves the wsdl first but that's where the error occurs. I saved the certificate in IE on my local machine and created a keystore from it, as described in JAX-WS-https-client and changed JVM arguments so that the keystore loads.
This did achieve that the url used to retrieve the wsdl contained protocol https instead of http, so things started to look better. But now I get the following error:
SystemException: PropagatedException: WSDLException: faultCode=OTHER_ERROR: Unable to resolve imported document at 'https://www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx?wsdl'.: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Does this mean that the certificate was copied to filesystem incorrectly?
Is something else wrong? What to do?
I should note that when exporting a certificate from IE, the option is given to export the private key or not. When not exporting the private key, then it can be saved as .cer file which is necessary for creating the keystore. On the other hand, when I try to export the private key, the file extension is .pfx and this cannot be converted to a keystore.
My bad - I had Fiddler running and thus used a certificate issued by Fiddler.
When I added the real certificate to the keystore, the webservice call was OK.