I have been having some trouble getting the real message from a webservice.
The access used to work fine, but when I tried to test it again after sometime, AXIS 2 returned me a 403 HTTP Error.
org.apache.axis2.AxisFault: Transport error: 403 Error: Forbidden
I got to thinking what it might be, so I tried to access it through SOAP UI, and it showed me that my certificate expired.
Here's the message I got with SoapUI
The page requires a valid SSL client certificate
Your client certificate has expired or is not yet valid. A Secure Sockets Layer (SSL) client certificate is used for identifying you as a valid user of the resource.
There's more to the message, I just cut it short to keep the post as small as possible.
OK, no problem there yet, I just need to find a way to inform the user that his certificate may have expired (or any other error has happened), instead of only showing him a 403 Error.
I tried to access it with JAX-WS, and I got the same message, all I get is that, I tried looking into the exception, see if there were any hidden information there, but no luck. What I get is this:
com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 403: Forbidden
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.checkStatusCode(Unknown Source)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source)
at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
at com.sun.xml.internal.ws.client.Stub.process(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
Can anyone give me some pointers on what I can do to get the real message? Here's the code I'm using to access it
public static void main(String[] args){
try{
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
System.clearProperty("javax.net.ssl.keyStore");
System.clearProperty("javax.net.ssl.keyStorePassword");
System.clearProperty("javax.net.ssl.trustStore");
System.setProperty("javax.net.ssl.keyStore", "myCertificatePath");
System.setProperty("javax.net.ssl.keyStorePassword", "myCertificatePassword");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStore", "cacertsFilePath");
NfeRecepcao2 nfe = new NfeRecepcao2();
NfeDadosMsg dados = new NfeDadosMsg();
dados.getContent().add(getFileContent("C:\\teste.xml"));
NfeCabecMsg cabec = new NfeCabecMsg();
cabec.setCUF("35");
cabec.setVersaoDados("2.00");
Holder<NfeCabecMsg> header = new Holder<NfeCabecMsg>(cabec);
NfeRecepcao2Soap12 proxy = nfe.getNfeRecepcao2Soap12();
NfeRecepcaoLote2Result result = proxy.nfeRecepcaoLote2(dados, header);
for (Object o : result.getContent()){
System.out.println(o);
}
} catch (Exception e){
e.printStackTrace();
}
getFileContent only opens a file and generates a String from it's content.
Any pointers here would be of great assistance. Thank you all in advance