org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
Axis2的高手们,帮帮小弟吧.
6 个解决方案
#1
2009-07-22 19:47:54,578 INFO [org.apache.axis2.deployment.ModuleDeployer] - Deploying module: metadataExchange-1.5 - file:/F:/我的项目/webservice/kaila/WebRoot/WEB-INF/lib/mex-1.5.jar
======================
2009-07-22 19:47:54,781 INFO [org.apache.commons.httpclient.auth.AuthChallengeProcessor] - ntlm authentication scheme selected
2009-07-22 19:47:54,781 ERROR [org.apache.commons.httpclient.HttpMethodDirector] - Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials
org.apache.commons.httpclient.auth.InvalidCredentialsException: Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials
at org.apache.commons.httpclient.auth.NTLMScheme.authenticate(NTLMScheme.java:332)
at org.apache.commons.httpclient.HttpMethodDirector.authenticateHost(HttpMethodDirector.java:282)
at org.apache.commons.httpclient.HttpMethodDirector.authenticate(HttpMethodDirector.java:234)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:550)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:389)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:222)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.webservice.util.SmbpHttpAgentStub.helloWorld(SmbpHttpAgentStub.java:3460)
at com.ws.test.WebServiceTest01.main(WebServiceTest01.java:17)
2009-07-22 19:47:54,796 INFO [org.apache.commons.httpclient.HttpMethodDirector] - Failure authenticating with NTLM <any realm>@59.151.7.69:80
2009-07-22 19:47:54,796 INFO [org.apache.axis2.transport.http.HTTPSender] - Unable to sendViaPost to url[http://59.151.7.69/SmbpHttpAgent/SmbpHttpAgent.asmx]
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:295)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:190)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:389)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:222)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.webservice.util.SmbpHttpAgentStub.helloWorld(SmbpHttpAgentStub.java:3460)
at com.ws.test.WebServiceTest01.main(WebServiceTest01.java:17)
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:295)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:190)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:389)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:222)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.webservice.util.SmbpHttpAgentStub.helloWorld(SmbpHttpAgentStub.java:3460)
at com.ws.test.WebServiceTest01.main(WebServiceTest01.java:17)
我的报的错误是这样的.我的代码是这样的.
_serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);
// add HTTP basic
HttpTransportProperties.Authenticator basicAuthentication =
new HttpTransportProperties.Authenticator();
basicAuthentication.setUsername("4633");
basicAuthentication.setPassword("jdwx");
_serviceClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, basicAuthentication);
#2
后来经过到网上查询后,在生成的STUB代码里面加上Ntlm的认证就可以了.
代码如下:
//如果是外网的话,主机和域名一定要加上去.小弟就吃了这亏.
basicauth.setHost("xx.xx.x.xx");
basicauth.setDomain("xx.xx.xx.xx");
_serviceClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicauth);
关于wsdl2java小弟总结如下:
wsdl2java -uri AxisTest03_adb.wsdl -s -ss -sd -ssi -o src 如果用这么多的参数生成的话,生成的代码不是很理解,因为最关键的部分需要你去加..
建议生成的话用
wsdl2java -uri AxisTest03_adb.wsdl -p com.webservice -o src这个命令生成的代码直接就可以用了. -p表示生成代码后的包名.
对于写服务器端而言,看来这参数少加些还是有好处的.
代码如下:
_serviceClient = new org.apache.axis2.client.ServiceClient(
configurationContext, _service);
HttpTransportProperties.Authenticator basicauth = new HttpTransportProperties.Authenticator();
basicauth.setUsername("xxxx");
basicauth.setPassword("xxx");
//如果是外网的话,主机和域名一定要加上去.小弟就吃了这亏.
basicauth.setHost("xx.xx.x.xx");
basicauth.setDomain("xx.xx.xx.xx");
_serviceClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicauth);
关于wsdl2java小弟总结如下:
wsdl2java -uri AxisTest03_adb.wsdl -s -ss -sd -ssi -o src 如果用这么多的参数生成的话,生成的代码不是很理解,因为最关键的部分需要你去加..
建议生成的话用
wsdl2java -uri AxisTest03_adb.wsdl -p com.webservice -o src这个命令生成的代码直接就可以用了. -p表示生成代码后的包名.
对于写服务器端而言,看来这参数少加些还是有好处的.
#3
我试 还是有问题啊!
#4
minjiaren您好!方便把客户端最终调用的代码发上来,让我们参考一下吗?我这边还是报401问题。谢谢!
#5
我的也是这个东西有问题 ,HTTP头里没有验证的信息 ,这样加上的信息在HTTP头里能看到吗???
#6
POST / HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://www.asat-tech.com.cn/CIS/CISWebServicePortType/pki-loginRequest"
User-Agent: Axis2
Transfer-Encoding: chunked
Host: 192.168.10.35:1234
2ca
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:pki-login xmlns:ns1="http://www.asat-tech.com.cn/CIS"><userName xmlns="">锟筋建锟斤拷</userName><timeout xmlns="">30</timeout><userId xmlns="">9752a403bf1e1acb19a96ba3c85e46e6</userId><auditData xmlns=""><role>6</role><usbkey-name>aaaa</usbkey-name><app-name>IISExplorerRCP</app-name><host-name>192.168.10.35</host-name><signature>vyc/Cxd5qu4CBys2ZSHVY4Euds76zTAFSHRFDGSDEp2GCID/Eu4jnqtlfzQ74wtqM2kSe9N7Dd2L
y+RaJVGDV1RizvElvrbnsDCRxDe5AZYbgO3IEjQCrQB7mj1pY/pNgynjUlNaVr5ttZEbuCUBwaSJ
kAidaJLe9bPkCsdV3G8=</signature></auditData></ns1:pki-login></soapenv:Body></soapenv:Envelope>
0
这是截取到的POST信息 ,为什么头里没有啊
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://www.asat-tech.com.cn/CIS/CISWebServicePortType/pki-loginRequest"
User-Agent: Axis2
Transfer-Encoding: chunked
Host: 192.168.10.35:1234
2ca
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:pki-login xmlns:ns1="http://www.asat-tech.com.cn/CIS"><userName xmlns="">锟筋建锟斤拷</userName><timeout xmlns="">30</timeout><userId xmlns="">9752a403bf1e1acb19a96ba3c85e46e6</userId><auditData xmlns=""><role>6</role><usbkey-name>aaaa</usbkey-name><app-name>IISExplorerRCP</app-name><host-name>192.168.10.35</host-name><signature>vyc/Cxd5qu4CBys2ZSHVY4Euds76zTAFSHRFDGSDEp2GCID/Eu4jnqtlfzQ74wtqM2kSe9N7Dd2L
y+RaJVGDV1RizvElvrbnsDCRxDe5AZYbgO3IEjQCrQB7mj1pY/pNgynjUlNaVr5ttZEbuCUBwaSJ
kAidaJLe9bPkCsdV3G8=</signature></auditData></ns1:pki-login></soapenv:Body></soapenv:Envelope>
0
这是截取到的POST信息 ,为什么头里没有啊
#1
2009-07-22 19:47:54,578 INFO [org.apache.axis2.deployment.ModuleDeployer] - Deploying module: metadataExchange-1.5 - file:/F:/我的项目/webservice/kaila/WebRoot/WEB-INF/lib/mex-1.5.jar
======================
2009-07-22 19:47:54,781 INFO [org.apache.commons.httpclient.auth.AuthChallengeProcessor] - ntlm authentication scheme selected
2009-07-22 19:47:54,781 ERROR [org.apache.commons.httpclient.HttpMethodDirector] - Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials
org.apache.commons.httpclient.auth.InvalidCredentialsException: Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials
at org.apache.commons.httpclient.auth.NTLMScheme.authenticate(NTLMScheme.java:332)
at org.apache.commons.httpclient.HttpMethodDirector.authenticateHost(HttpMethodDirector.java:282)
at org.apache.commons.httpclient.HttpMethodDirector.authenticate(HttpMethodDirector.java:234)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:550)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:389)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:222)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.webservice.util.SmbpHttpAgentStub.helloWorld(SmbpHttpAgentStub.java:3460)
at com.ws.test.WebServiceTest01.main(WebServiceTest01.java:17)
2009-07-22 19:47:54,796 INFO [org.apache.commons.httpclient.HttpMethodDirector] - Failure authenticating with NTLM <any realm>@59.151.7.69:80
2009-07-22 19:47:54,796 INFO [org.apache.axis2.transport.http.HTTPSender] - Unable to sendViaPost to url[http://59.151.7.69/SmbpHttpAgent/SmbpHttpAgent.asmx]
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:295)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:190)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:389)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:222)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.webservice.util.SmbpHttpAgentStub.helloWorld(SmbpHttpAgentStub.java:3460)
at com.ws.test.WebServiceTest01.main(WebServiceTest01.java:17)
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:295)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:190)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:389)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:222)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.webservice.util.SmbpHttpAgentStub.helloWorld(SmbpHttpAgentStub.java:3460)
at com.ws.test.WebServiceTest01.main(WebServiceTest01.java:17)
我的报的错误是这样的.我的代码是这样的.
_serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);
// add HTTP basic
HttpTransportProperties.Authenticator basicAuthentication =
new HttpTransportProperties.Authenticator();
basicAuthentication.setUsername("4633");
basicAuthentication.setPassword("jdwx");
_serviceClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, basicAuthentication);
#2
后来经过到网上查询后,在生成的STUB代码里面加上Ntlm的认证就可以了.
代码如下:
//如果是外网的话,主机和域名一定要加上去.小弟就吃了这亏.
basicauth.setHost("xx.xx.x.xx");
basicauth.setDomain("xx.xx.xx.xx");
_serviceClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicauth);
关于wsdl2java小弟总结如下:
wsdl2java -uri AxisTest03_adb.wsdl -s -ss -sd -ssi -o src 如果用这么多的参数生成的话,生成的代码不是很理解,因为最关键的部分需要你去加..
建议生成的话用
wsdl2java -uri AxisTest03_adb.wsdl -p com.webservice -o src这个命令生成的代码直接就可以用了. -p表示生成代码后的包名.
对于写服务器端而言,看来这参数少加些还是有好处的.
代码如下:
_serviceClient = new org.apache.axis2.client.ServiceClient(
configurationContext, _service);
HttpTransportProperties.Authenticator basicauth = new HttpTransportProperties.Authenticator();
basicauth.setUsername("xxxx");
basicauth.setPassword("xxx");
//如果是外网的话,主机和域名一定要加上去.小弟就吃了这亏.
basicauth.setHost("xx.xx.x.xx");
basicauth.setDomain("xx.xx.xx.xx");
_serviceClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicauth);
关于wsdl2java小弟总结如下:
wsdl2java -uri AxisTest03_adb.wsdl -s -ss -sd -ssi -o src 如果用这么多的参数生成的话,生成的代码不是很理解,因为最关键的部分需要你去加..
建议生成的话用
wsdl2java -uri AxisTest03_adb.wsdl -p com.webservice -o src这个命令生成的代码直接就可以用了. -p表示生成代码后的包名.
对于写服务器端而言,看来这参数少加些还是有好处的.
#3
我试 还是有问题啊!
#4
minjiaren您好!方便把客户端最终调用的代码发上来,让我们参考一下吗?我这边还是报401问题。谢谢!
#5
我的也是这个东西有问题 ,HTTP头里没有验证的信息 ,这样加上的信息在HTTP头里能看到吗???
#6
POST / HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://www.asat-tech.com.cn/CIS/CISWebServicePortType/pki-loginRequest"
User-Agent: Axis2
Transfer-Encoding: chunked
Host: 192.168.10.35:1234
2ca
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:pki-login xmlns:ns1="http://www.asat-tech.com.cn/CIS"><userName xmlns="">锟筋建锟斤拷</userName><timeout xmlns="">30</timeout><userId xmlns="">9752a403bf1e1acb19a96ba3c85e46e6</userId><auditData xmlns=""><role>6</role><usbkey-name>aaaa</usbkey-name><app-name>IISExplorerRCP</app-name><host-name>192.168.10.35</host-name><signature>vyc/Cxd5qu4CBys2ZSHVY4Euds76zTAFSHRFDGSDEp2GCID/Eu4jnqtlfzQ74wtqM2kSe9N7Dd2L
y+RaJVGDV1RizvElvrbnsDCRxDe5AZYbgO3IEjQCrQB7mj1pY/pNgynjUlNaVr5ttZEbuCUBwaSJ
kAidaJLe9bPkCsdV3G8=</signature></auditData></ns1:pki-login></soapenv:Body></soapenv:Envelope>
0
这是截取到的POST信息 ,为什么头里没有啊
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://www.asat-tech.com.cn/CIS/CISWebServicePortType/pki-loginRequest"
User-Agent: Axis2
Transfer-Encoding: chunked
Host: 192.168.10.35:1234
2ca
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:pki-login xmlns:ns1="http://www.asat-tech.com.cn/CIS"><userName xmlns="">锟筋建锟斤拷</userName><timeout xmlns="">30</timeout><userId xmlns="">9752a403bf1e1acb19a96ba3c85e46e6</userId><auditData xmlns=""><role>6</role><usbkey-name>aaaa</usbkey-name><app-name>IISExplorerRCP</app-name><host-name>192.168.10.35</host-name><signature>vyc/Cxd5qu4CBys2ZSHVY4Euds76zTAFSHRFDGSDEp2GCID/Eu4jnqtlfzQ74wtqM2kSe9N7Dd2L
y+RaJVGDV1RizvElvrbnsDCRxDe5AZYbgO3IEjQCrQB7mj1pY/pNgynjUlNaVr5ttZEbuCUBwaSJ
kAidaJLe9bPkCsdV3G8=</signature></auditData></ns1:pki-login></soapenv:Body></soapenv:Envelope>
0
这是截取到的POST信息 ,为什么头里没有啊