2

基本 HTTP 認証を持つ Web サービスを呼び出そうとしています。AXIS の WSDL2JAVA ツールを使用してクライアント コードを生成しました。

しかし、ユーザー名とパスワードを Web サービス呼び出しに設定できません。

私はそれらをエンドポイントのURLに入れようとしました

http://ユーザー名:パスワード@somwserver/wsdl

しかし、これに対して不正なエラーが発生しています。Javaコードでこのセットを私の呼び出しに設定する方法を見つけようとしています....

注 : soapUI を介して同じサービスを呼び出し、結果を取得できます。リクエストの「Aut」タブにユーザー名とパスワードを入力しました。

これがあなたにとって役に立つなら、私のスタブのコードスニペットの一部です

       _serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);


    _serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(
            targetEndpoint));
    _serviceClient.getOptions().setUseSeparateListener(useSeparateListener);

        //adding SOAP soap_headers
     _serviceClient.addHeadersToEnvelope(env);
    // set the message context with that soap envelope
    _messageContext.setEnvelope(env);

    // add the message contxt to the operation client
    _operationClient.addMessageContext(_messageContext);

    //execute the operation client
    _operationClient.execute(true);

どんな入力でも大歓迎です!!

4

1 に答える 1

6
 HttpTransportProperties.Authenticator
                       auth = new HttpTransportProperties.Authenticator();
            auth.setUsername("username");
            auth.setPassword("password");

 _serviceClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATE,auth);
于 2010-08-29T03:26:35.277 に答える