我從web服務獲取真正的消息時遇到了一些麻煩。如何獲得真正的Web服務響應,而不是403錯誤?
訪問用於正常工作,但是當我試圖在某個時間後再次測試它時,AXIS 2向我返回了403 HTTP錯誤。
org.apache.axis2.AxisFault: Transport error: 403 Error: Forbidden
我想到它可能是什麼,所以我試圖通過SOAP UI訪問它,它告訴我我的證書已過期。
這是我用了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.
還有更多的消息得到了消息,我只是把它剪短,以保持後儘可能小。
好吧,那裏沒有問題,我只需要找到一種方法來通知用戶他的證書可能已經過期(或任何其他錯誤發生),而不是隻顯示他一個403錯誤。
我試圖用JAX-WS訪問它,並且我得到了相同的消息,我得到的是我試圖查找異常,看看有沒有隱藏的信息,但沒有運氣。我得到的是這樣的:
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)
任何人都可以給我一些關於我能做些什麼來獲得真正的消息?下面是我用來訪問它
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的代碼只打開一個文件,並生成一個字符串,從它的內容。
這裏的任何指針都會有很大的幫助。謝謝大家提前