最近我得到了我們的一位客戶的要求。他們提供了一個WSDL來調用他們的服務。他們正在進行IP白名單進行身份驗證。我給了我的服務器公共IP,並將其列入白名單。首先,我通過SOAP UI工具測試了該服務,並且沒有任何問題。然後我通過JAVA代碼集成,並失敗。我得到一個異常像獲取401錯誤在製作肥皂請求時未經授權
Unable to sendViaPost to url[ https://apps.greystar.com/gsWebService/gsExtract.asmx] org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.handleResponse(HTTPSenderImpl.java:343) ~[axis2-transport-http-1.7.1.jar:1.7.1] at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:213) ~[axis2-transport-http-1.7.1.jar:1.7.1] at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121) [axis2-transport-http-1.7.1.jar:1.7.1] at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:403) [axis2-transport-http-1.7.1.jar:1.7.1] at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:234) [axis2-transport-http-1.7.1.jar:1.7.1] at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:431) [axis2-kernel-1.7.1.jar:1.7.1] at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399) [axis2-kernel-1.7.1.jar:1.7.1] at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225) [axis2-kernel-1.7.1.jar:1.7.1] at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150) [axis2-kernel-1.7.1.jar:1.7.1] at com.reputation.r4e.integrator.greystar.ExtractDataStub.greystarExtract(ExtractDataStub.java:300) [classes/:na] at com.reputation.r4e.integrator.recordreader.GreystarLocationImportRecordReader.getGreystarExtractResponse(GreystarLocationImportRecordReader.java:198) [classes/:na] at com.reputation.r4e.integrator.recordreader.GreystarLocationImportRecordReader.process(GreystarLocationImportRecordReader.java:97) [classes/:na] at com.reputation.r4e.integrator.impl.DefaultPipeline.flow(DefaultPipeline.java:33) [classes/:na] at com.reputation.r4e.integrator.impl.DefaultPipeline.process(DefaultPipeline.java:52) [classes/:na] at com.reputation.r4e.integrator.importer.NullImporter.process(NullImporter.java:38) [classes/:na] at com.reputation.r4e.integrator.impl.DefaultPipeline.flow(DefaultPipeline.java:33) [classes/:na] at com.reputation.r4e.integrator.impl.DefaultPipeline.process(DefaultPipeline.java:52) [classes/:na] at com.reputation.r4e.integrator.IntegrationRunner$IntegrationRunnable.run(IntegrationRunner.java:87) [classes/:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
這是說401未經授權的錯誤。它是如何通過SOAP UI工作的,以及它爲什麼不通過JAVA客戶端工作。
我監測通過TCPMon的HTTP流量和除了標題都是相同的。所以我添加了從SOAP UI工具獲得的頭文件到我的JAVA客戶端,但仍然沒有運氣。我得到相同的401未經授權的錯誤。
下面是SOAP UI和通過JAVA客戶端的SOAP請求。
SOAP UI請求:
POST https://apps.greystar.com/gsWebService/gsExtract.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/soap+xml;charset=UTF-8;action="https://apps.greystar.com/greystarExtract"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Content-Length: 692
Host: apps.greystar.com
Connection: Keep-Alive
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:apps="https://apps.greystar.com/">
<soap:Header/>
<soap:Body>
<apps:greystarExtract>
<apps:axmlVendorCode>VENDOR_CODE</apps:axmlVendorCode>
<apps:axmlToken>PASSWORD</apps:axmlToken>
<apps:axmlExtractType>PROPERTY_LIST</apps:axmlExtractType>
<apps:axmlFormat>XML</apps:axmlFormat>
<apps:axmlParameters></apps:axmlParameters>
</apps:greystarExtract>
</soap:Body>
</soap:Envelope>
JAVA客戶端請求:
POST /gsWebService/gsExtract.asmx HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8; action="https://apps.greystar.com/greystarExtract
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36[\r][\n]
Connection: Keep-Alive
Host: apps.greystar.com
Transfer-Encoding: chunked
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header />
<soapenv:Body>
<ns1:greystarExtract xmlns:ns1="https://apps.greystar.com/">
<ns1:axmlVendorCode>VENDOR_CODE</ns1:axmlVendorCode>
<ns1:axmlToken>PASSWORD</ns1:axmlToken>
<ns1:axmlExtractType>PROPERTY_LIST</ns1:axmlExtractType>
<ns1:axmlFormat>JSON</ns1:axmlFormat>
<ns1:axmlParameters></ns1:axmlParameters>
</ns1:greystarExtract>
</soapenv:Body>
</soapenv:Envelope>
注:我通過看SOAP UI頭添加Java客戶端頭。實際的JAVA客戶端標題如下
POST /gsWebService/gsExtract.asmx HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8;
action="https://apps.greystar.com/greystarExtract
User-Agent: Axis2
Host: apps.greystar.com
Transfer-Encoding: chunked
什麼可能是通過JAVA客戶端失敗的原因?任何人都可以回答我的問題,因爲我困在這裏。
由於提前, Amar.T
是目標服務器上的證書是否有效? – BlackFlag
我只是使用該服務的用戶。我不知道服務器代碼。如果證書無效,那麼通過SOAP UI得到了什麼。 – Amar
那麼最後一次我試圖在android中實現肥皂我得到了當服務器證書無效,因此不信任。所以框架決定停止溝通。如果您嘗試在瀏覽器中打開wsdl,會發生什麼情況?你看到有效的證書嗎? – BlackFlag