Hi All,
Have some questions here, because I still cannot manage to connect via SSL.
I get the error below from the client code, can someone tell me what's wrong here?
--------------------------------------------------------------------------------
java.rmi.RemoteException: cannot connect to server: Unauthorized; nested exception is:
cannot connect to server: Unauthorized
at hello.HelloIF_Stub.sayHello(HelloIF_Stub.java:77)
at hello.HelloClient.main(HelloClient.java:10)
Caused by: cannot connect to server: Unauthorized
at com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpClientTran
sport.java:119)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:73)
at hello.HelloIF_Stub.sayHello(HelloIF_Stub.java:60)
... 1 more
--------------------------------------------------------------------------------
Here's the Client code:
package hello;
import javax.xml.rpc.Stub;
public class HelloClient
{
public static void main(String[] args)
{
try
{
System.setProperty ("javax.net.ssl.trustStore", "f:\\SSL\\client.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "12345678");
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
HelloIF_Stub stub = (HelloIF_Stub)( new HelloService_Impl().getHelloIFPort() );
stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
"
https://192.168.168.88:443/helloservice/endpoint/HelloIF");
stub._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, "honluen");
stub._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, "12345678");
HelloIF hello = (HelloIF)stub;
System.out.println(hello.sayHello("DSSS!"));
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
--------------------------------------------------------------------------------
Note: The Web Service machine is installed with tomcat with SSL enabled on port 443.
On the Web Service machine:
Here's the web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"
http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<web-app>
<display-name>hello Application</display-name>
<description>A web application containing a JAX-RPC endpoint</description>
<security-constraint>
<web-resource-collection>
<web-resource-name>MyServiceName</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<servlet>
<servlet-name>JAXRPCEndpoint</servlet-name>
<display-name>JAXRPCEndpoint</display-name>
<description>Endpoint for hello Service</description>
<servlet-class>com.sun.xml.rpc.server.http.JAXRPCServlet</servlet-class>
<init-param>
<param-name>configuration.file</param-name>
<param-value>/WEB-INF/HelloService_Config.properties</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAXRPCEndpoint</servlet-name>
<url-pattern>/endpoint/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>