0

Cognos のカスタム認証プロバイダーに取り組んでいます。認証リクエストをリッスンする Web サービスがあります。テスト目的で、ユーザー/パスを送信しようとしています (後でセッション情報を使用するように変更されます)。

カスタム プロバイダーを実装する前に、単純な Java コンソール アプリで POC を動作させようとしました。クライアントが Web サービスと通信するのに問題があります。wsimport を使用して、keep フラグを使用してクラスを生成しました。生成された Java ファイルを Eclipse プロジェクトに取り込み、次のようなメイン メソッドを作成しました。

CognosAuthentication service = new CognosAuthentication();

CognosAuthenticationSoap soapClient = service.getCognosAuthenticationSoap();

CognosUser user = soapClient.validateDevSession("username", "password");

System.out.println(user == null ? "User was null" : user.getUserName());

サービスの URL も指定してみました (末尾に「?wsdl」を追加する場合と追加しない場合の両方):

CognosAuthentication service = new CognosAuthentication(new URL("http://somehost/CognosAuthentication.asmx"), new QName("http://tempuri.org/", "CognosAuthentication"));

サービスによって生成される WSDL は次の場所にあります。

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s1="http://www.ourcompany.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
      <s:import namespace="http://www.ourcompany.com/" />
      <s:element name="ValidateSession">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="username" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="expires" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="userId" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="authToken" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="ValidateSessionResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" ref="s1:ValidateSessionResult" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="ValidateDevSession">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="username" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="ValidateDevSessionResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" ref="s1:ValidateDevSessionResult" />
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.ourcompany.com/">
      <s:element name="ValidateSessionResult" nillable="true" type="s1:CognosUser" />
      <s:complexType name="CognosUser">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="CognosSlot" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="GroupName" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" />
        </s:sequence>
      </s:complexType>
      <s:element name="ValidateDevSessionResult" nillable="true" type="s1:CognosUser" />
    </s:schema>
  </wsdl:types>
  <wsdl:message name="ValidateSessionSoapIn">
    <wsdl:part name="parameters" element="tns:ValidateSession" />
  </wsdl:message>
  <wsdl:message name="ValidateSessionSoapOut">
    <wsdl:part name="parameters" element="tns:ValidateSessionResponse" />
  </wsdl:message>
  <wsdl:message name="ValidateDevSessionSoapIn">
    <wsdl:part name="parameters" element="tns:ValidateDevSession" />
  </wsdl:message>
  <wsdl:message name="ValidateDevSessionSoapOut">
    <wsdl:part name="parameters" element="tns:ValidateDevSessionResponse" />
  </wsdl:message>
  <wsdl:portType name="CognosAuthenticationSoap">
    <wsdl:operation name="ValidateSession">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Gets user information based on the authentication token</wsdl:documentation>
      <wsdl:input message="tns:ValidateSessionSoapIn" />
      <wsdl:output message="tns:ValidateSessionSoapOut" />
    </wsdl:operation>
    <wsdl:operation name="ValidateDevSession">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Gets user information based on the authentication token</wsdl:documentation>
      <wsdl:input message="tns:ValidateDevSessionSoapIn" />
      <wsdl:output message="tns:ValidateDevSessionSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="CognosAuthenticationSoap" type="tns:CognosAuthenticationSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="ValidateSession">
      <soap:operation soapAction="http://tempuri.org/ValidateSession" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ValidateDevSession">
      <soap:operation soapAction="http://tempuri.org/ValidDevSession" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="CognosAuthenticationSoap12" type="tns:CognosAuthenticationSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="ValidateSession">
      <soap12:operation soapAction="http://tempuri.org/ValidateSession" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ValidateDevSession">
      <soap12:operation soapAction="http://tempuri.org/ValidDevSession" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="CognosAuthentication">
    <wsdl:port name="CognosAuthenticationSoap" binding="tns:CognosAuthenticationSoap">
      <soap:address location="http://mbeard2/LMS/app/analytics/CognosAuthentication.asmx" />
    </wsdl:port>
    <wsdl:port name="CognosAuthenticationSoap12" binding="tns:CognosAuthenticationSoap12">
      <soap12:address location="http://mbeard2/LMS/app/analytics/CognosAuthentication.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

wsimport を使用してすべての正しい手順を実行したと仮定します。私が直面している問題は、それが何もしないということです。フィドラーを起動して、ネットワーク トラフィックが発生していないことを確認できます。ユーザーオブジェクトは常に null です。設定する必要があるものはありますか? Web サービスが C#/ASP.NET サービスであることに何かおかしなことはありますか? SOAP 要求構造の使用方法に何か不足していますか?

コンパイル時やコードの実行時にエラーは発生しません。答えを求めて頭を悩ませています!

4

1 に答える 1

0

SOには、「私は劣等生なので質問を閉じる」オプションが必要です。どういうわけか、フィドラーは要求を受け入れていませんでした。Web サービスに接続されたリモート デバッグを取得したところ、パスワードを間違って入力したため、要求が受信されて追い出されたことがわかりました。しかたがない...

于 2011-03-18T15:20:56.760 に答える