org.apache.axis2.AxisFault:传输错误:401 错误:在 Tomcat 上调用 Web 服务时未经授权

发布于 2024-12-11 17:30:37 字数 5460 浏览 0 评论 0原文

apache.axis2.AxisFault:传输错误:401 错误:调用 Tomcat 6.0.13 上部署的 Web 服务时出现未经授权的异常,请查找堆栈跟踪,如下所示: log4j:WARN 找不到记录器 (org.apache.axis2.1) 的附加程序。描述.AxisService)。 log4j:WARN 请正确初始化 log4j 系统。 HSYS:sysuser00:10.112.209.51:6500:空:80:空 [SO_TIMEOUT,_NTLM_DIGEST_BASIC_AUTHENTICATION_] 300000 org.apache.axis2.transport.http.HttpTransportProperties$Authenticator@fc9944 HSYS:sysuser00 org.apache.axis2.AxisFault:传输错误:401错误:未经授权在org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:296)在org.apache.axis2.transport.http.HTTPSender.sendViaPost (HTTPSender.java:190)位于org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75) 在 org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:371) 在 org.apache.axis2.transport。 http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:209) 在org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435) 在 org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402) 在 org.apache.axis2.description.OutInAxisOperationClient.executeImpl( OutInAxisOperation.java:229) 在org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) 位于 com.test.CmPersonUpServiceStub.cmPersonUp(CmPersonUpServiceStub.java:228) 位于 com.test.CmPersonUpServiceTest.testcmPersonUp(CmPersonUpServiceTest.java:69) com.test.CmPersonUpServiceTest.main(CmPersonUpServiceTest.java:85) ------------------------------------ -------------------------------------------------- ---------------------------- `请找到我的测试调用类如下:

/**
 * CmPersonUpServiceTest.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis2 version: 1.5  Built on : Apr 30, 2009 (06:07:24 EDT)
 */
    package com.test;

import java.util.ArrayList;
import java.util.List;

import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator;

import com.oracle.cmpersonup_xsd.CmPersonUp;

    /*
     *  CmPersonUpServiceTest Junit test case
    */

    public class CmPersonUpServiceTest {


        /**
         * Auto generated test method
         */
        public  void testcmPersonUp() throws java.lang.Exception{

        com.test.CmPersonUpServiceStub stub =
                    new com.test.CmPersonUpServiceStub();//the default implementation should point to the right endpoint




        Options opt = stub._getServiceClient().getOptions();
        EndpointReference epr = new EndpointReference("http://10.112.209.51:6500/spl/XAIApp/xaiserver/CmPersonUp");
        opt.setTo(epr); 
        opt.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(300000));
        HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
        List<String> auth = new ArrayList<String>();
        auth.add(Authenticator.BASIC);
        authenticator.setAuthSchemes(auth);
        authenticator.setUsername("HSYS");
        authenticator.setPassword("sysuser00");
        authenticator.setHost("10.112.209.51:6500");
        authenticator.setPort(80);
        authenticator.setPreemptiveAuthentication(true);
        opt.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
        stub._getServiceClient().setOptions(opt);

        Options opt1 = stub._getServiceClient().getOptions();
        if(opt1.getProperty(HTTPConstants.AUTHENTICATE)!=null){
        Authenticator authenticator1=(Authenticator)opt1.getProperty(HTTPConstants.AUTHENTICATE);
        System.out.println(authenticator1.getUsername()+" : "+authenticator1.getPassword()+" : "+authenticator1.getHost()+" : "+authenticator1.getDomain()+" : "+authenticator1.getPort()+" : "+authenticator1.getRealm());
        }
        else System.out.println("opt1.getProperty(HTTPConstants.AUTHENTICATE); is null ");
           com.oracle.cmpersonup_xsd.CmPersonUp cmPersonUp5=
                                                        (com.oracle.cmpersonup_xsd.CmPersonUp)getTestObject(com.oracle.cmpersonup_xsd.CmPersonUp.class);
                    // TODO : Fill in the cmPersonUp5 here
           cmPersonUp5.setPersonId("0272100000");
           cmPersonUp5.setPersonEmailId("[email protected]");
            cmPersonUp5.setFaultStyle("wsdl");
           CmPersonUp response=stub.cmPersonUp(cmPersonUp5);
           System.out.println(response.getPersonEmailId()+" ------>>>>>> "+response.getPersonId()+" ------->>>>>>> "+response.getPersonBirthDay());

        }

        //Create an ADBBean and provide it as the test object
        public org.apache.axis2.databinding.ADBBean getTestObject(java.lang.Class type) throws java.lang.Exception{
           return (org.apache.axis2.databinding.ADBBean) type.newInstance();
        }

        public static void main(String[] args) {
            CmPersonUpServiceTest test = new CmPersonUpServiceTest();
            try {
                test.testcmPersonUp();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }


    }

请在这件事上提供您的帮助。`

apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized exception while invoking the webservice deployed on Tomcat 6.0.13 please find the stack trace as given below: log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisService). log4j:WARN Please initialize the log4j system properly. HSYS : sysuser00 : 10.112.209.51:6500 : null : 80 : null [SO_TIMEOUT, _NTLM_DIGEST_BASIC_AUTHENTICATION_] 300000 org.apache.axis2.transport.http.HttpTransportProperties$Authenticator@fc9944 HSYS : sysuser00 org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:296) 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:371) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:209) 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.test.CmPersonUpServiceStub.cmPersonUp(CmPersonUpServiceStub.java:228) at com.test.CmPersonUpServiceTest.testcmPersonUp(CmPersonUpServiceTest.java:69) at com.test.CmPersonUpServiceTest.main(CmPersonUpServiceTest.java:85) ------------------------------------------------------------------------------------------------------------------ `please find my test invocation class as below :

/**
 * CmPersonUpServiceTest.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis2 version: 1.5  Built on : Apr 30, 2009 (06:07:24 EDT)
 */
    package com.test;

import java.util.ArrayList;
import java.util.List;

import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator;

import com.oracle.cmpersonup_xsd.CmPersonUp;

    /*
     *  CmPersonUpServiceTest Junit test case
    */

    public class CmPersonUpServiceTest {


        /**
         * Auto generated test method
         */
        public  void testcmPersonUp() throws java.lang.Exception{

        com.test.CmPersonUpServiceStub stub =
                    new com.test.CmPersonUpServiceStub();//the default implementation should point to the right endpoint




        Options opt = stub._getServiceClient().getOptions();
        EndpointReference epr = new EndpointReference("http://10.112.209.51:6500/spl/XAIApp/xaiserver/CmPersonUp");
        opt.setTo(epr); 
        opt.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(300000));
        HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
        List<String> auth = new ArrayList<String>();
        auth.add(Authenticator.BASIC);
        authenticator.setAuthSchemes(auth);
        authenticator.setUsername("HSYS");
        authenticator.setPassword("sysuser00");
        authenticator.setHost("10.112.209.51:6500");
        authenticator.setPort(80);
        authenticator.setPreemptiveAuthentication(true);
        opt.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
        stub._getServiceClient().setOptions(opt);

        Options opt1 = stub._getServiceClient().getOptions();
        if(opt1.getProperty(HTTPConstants.AUTHENTICATE)!=null){
        Authenticator authenticator1=(Authenticator)opt1.getProperty(HTTPConstants.AUTHENTICATE);
        System.out.println(authenticator1.getUsername()+" : "+authenticator1.getPassword()+" : "+authenticator1.getHost()+" : "+authenticator1.getDomain()+" : "+authenticator1.getPort()+" : "+authenticator1.getRealm());
        }
        else System.out.println("opt1.getProperty(HTTPConstants.AUTHENTICATE); is null ");
           com.oracle.cmpersonup_xsd.CmPersonUp cmPersonUp5=
                                                        (com.oracle.cmpersonup_xsd.CmPersonUp)getTestObject(com.oracle.cmpersonup_xsd.CmPersonUp.class);
                    // TODO : Fill in the cmPersonUp5 here
           cmPersonUp5.setPersonId("0272100000");
           cmPersonUp5.setPersonEmailId("[email protected]");
            cmPersonUp5.setFaultStyle("wsdl");
           CmPersonUp response=stub.cmPersonUp(cmPersonUp5);
           System.out.println(response.getPersonEmailId()+" ------>>>>>> "+response.getPersonId()+" ------->>>>>>> "+response.getPersonBirthDay());

        }

        //Create an ADBBean and provide it as the test object
        public org.apache.axis2.databinding.ADBBean getTestObject(java.lang.Class type) throws java.lang.Exception{
           return (org.apache.axis2.databinding.ADBBean) type.newInstance();
        }

        public static void main(String[] args) {
            CmPersonUpServiceTest test = new CmPersonUpServiceTest();
            try {
                test.testcmPersonUp();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }


    }

Please provide your assistance in this matter.`

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花之痕靓丽 2024-12-18 17:30:37

401错误意味着目标URL受到保护,您需要提供用户名/密码身份验证。

您需要在客户端中设置用户名和密码,或者调整服务器设置以使服务不受保护。

检查TemperatureConverterStub 类中是否有允许您设置用户名/密码的方法,或者检查您用来创建这些类的工具的文档以获取更多信息。

A 401 error means that the target URL is protected, and you need to provide username/password authentication.

you need to set the username and password in the client, or tune your server settings so that the service is not protected.

Check the TemperatureConverterStub class for methods that allow you to set username/password, or check the documentation of whichever tool you're using to create those classes for more information on this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文