简体   繁体   English

获取401错误在发出肥皂请求时未经授权

[英]Getting 401 error Unauthorized while making soap request

Recently I got a requirement from one of our customer. 最近我收到了一位客户的要求。 They provided a WSDL to call their service. 他们提供了一个WSDL来调用他们的服务。 They are doing IP whitelisting for authentication. 他们正在进行IP白名单以进行身份​​验证。 I gave my server public IP and it got whitelisted. 我给了我的服务器公共IP,它被列入白名单。 First, I tested that service through SOAP UI tool and it got worked without any issues. 首先,我通过SOAP UI工具测试了该服务,并且它没有任何问题。 Then I integrated through JAVA code and it got failed. 然后我通过JAVA代码集成,它失败了。 I am getting an exception like 我得到一个例外

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.OutInAxisO 无法将viaPost发送到网址[ https://apps.greystar.com/gsWebService/gsExtract.asmx] org.apache.axis2.AxisFault:传输错误:401错误:未经授权在 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] atg.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121)[ axis2-transport-http -1.7.1.jar:1.7.1]在org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:403)[axis2-transport-http-1.7.1.jar:1.7.1] at at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:234)[axis2-transport-http-1.7.1.jar:1.7.1] org.apache.axis2.engine.AxisEngine.send( AxisEngine.java:431)[axis2-kernel-1.7.1.jar:1.7.1] org.apache.axis2.description.OutInAxisO perationClient.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.p perationClient.send(OutInAxisOperation.java:399)[axis2-kernel-1.7.1.jar:1.7.1] atg.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)[ axis2-kernel-1.7 .jar:1.7.1]在com.reputation.r4e的org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)[axis2-kernel-1.7.1.jar:1.7.1]。 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 ] com.reputation.r4e.integrator.impl.DefaultPipeline.process(DefaultPipeline.java:52)[classes /:na] at com.reputation.r4e.integrator.importer.NullImporter.p rocess(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] rocess(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]

It's saying 401 unauthorised error. 这是说401未经授权的错误。 How it got worked through SOAP UI and why its not working through a JAVA client.? 它是如何通过SOAP UI工作的,以及为什么它不能通过JAVA客户端工作。

I monitor http traffic through TCPMon and except headers all are same. 我通过TCPMon监控http流量,除了标头都相同。 So I added the headers which got from the SOAP UI tool to my JAVA Client but still no luck. 所以我添加了从SOAP UI工具到我的JAVA Client的标题,但仍然没有运气。 I am getting the same 401 unauthorised error. 我得到了同样的401未经授权的错误。

Here are the soap request of both SOAP UI and through JAVA Client. 以下是SOAP UI和JAVA Client的soap请求。

SOAP UI Request: 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 CLIENT Request: 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>

Note: I added JAVA Client headers by looking at the SOAP UI headers. 注意:我通过查看SOAP UI标头添加了JAVA Client标头。 The actual JAVA client headers are below 实际的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

What could be the reason for failing this through JAVA client.? 通过JAVA客户端失败的原因可能是什么? Can any one please answer my question because I stuck over here. 任何人都可以回答我的问题,因为我坚持到这里。

Thanks in advance, Amar.T 在此先感谢,Amar.T

I tried other third party libraries and its working as expected. 我尝试了其他第三方库,并按预期工作。 I tried CXF and SOAP UI JAVA API and its working as expected. 我尝试了CXF和SOAP UI JAVA API ,并按预期工作。 I don't know why its not working with APACHE AXIS2. 我不知道为什么它不能与APACHE AXIS2合作。

If anyone finds the answer why its not working with AXIS2 please post the answer. 如果有人找到答案,为什么它不与AXIS2合作,请发布答案。

Thanks & Regards, Amar.T 感谢和问候,Amar.T

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 消费SOAP WS返回未经授权的错误401 - Consuming SOAP WS returns Error 401 unauthorized 在改造中获得401未经授权的错误? - Getting 401 unauthorized error in retrofit? 云端点返回错误401未经授权的请求 - cloud endpoints return error 401 unauthorized request 出现 401 未经授权的错误:Microsoft Graph API - Getting 401 Unauthorized Error : Microsoft Graph APIs 带有 Spring Boot 和 Mysql 的 JWT,得到错误“status”:401,“error”:“Unauthorized”,同时提供访问角色 - JWT with Spring Boot and Mysql, getting an error "status": 401, "error": "Unauthorized", while giving an access roles 获取TokenResponseException:401未经授权 - getting TokenResponseException: 401 Unauthorized 使用Java检索Riot API信息时获取401(未经授权) - Getting a 401 (Unauthorized) while using Java to retrieve Riot API information 尝试通过服务帐户进行身份验证时收到“ 401未经授权” - getting “401 Unauthorized” while trying to authenticated with service account 沃森语音转文本未经授权的请求错误401 - watson speech to text unauthorized request error401 为什么我在 Maven 中收到“401 Unauthorized”错误? - Why am I getting a "401 Unauthorized" error in Maven?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM