5

次のWSDL(トランスポートセキュリティにwsHttpBindingとSSLを使用する単純なサービス)を使用してWCFWebサービスをホストしています。

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="MagicEightBallService" targetNamespace="http://tempuri.org/">
  <wsp:Policy wsu:Id="WSHttpBinding_TransportSecurity_IMagicEightBallService_policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy>
            <sp:TransportToken>
              <wsp:Policy>
                <sp:HttpsToken RequireClientCertificate="false"/>
              </wsp:Policy>
            </sp:TransportToken>
            <sp:AlgorithmSuite>
              <wsp:Policy>
                <sp:Basic256/>
              </wsp:Policy>
            </sp:AlgorithmSuite>
            <sp:Layout>
              <wsp:Policy>
                <sp:Strict/>
              </wsp:Policy>
            </sp:Layout>
          </wsp:Policy>
        </sp:TransportBinding>
        <wsaw:UsingAddressing/>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsdl:types>
    <xsd:schema targetNamespace="http://tempuri.org/Imports">
      <xsd:import schemaLocation="http://my.local.domain.name/MagicEightBall/MagicEightBallService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
      <xsd:import schemaLocation="http://my.local.domain.name/MagicEightBall/MagicEightBallService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="IMagicEightBallService_GetAdvice_InputMessage">
    <wsdl:part name="parameters" element="tns:GetAdvice"/>
  </wsdl:message>
  <wsdl:message name="IMagicEightBallService_GetAdvice_OutputMessage">
    <wsdl:part name="parameters" element="tns:GetAdviceResponse"/>
  </wsdl:message>
  <wsdl:portType name="IMagicEightBallService">
    <wsdl:operation name="GetAdvice">
      <wsdl:input wsaw:Action="http://tempuri.org/IMagicEightBallService/GetAdvice" message="tns:IMagicEightBallService_GetAdvice_InputMessage"/>
      <wsdl:output wsaw:Action="http://tempuri.org/IMagicEightBallService/GetAdviceResponse" message="tns:IMagicEightBallService_GetAdvice_OutputMessage"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="WSHttpBinding_TransportSecurity_IMagicEightBallService" type="tns:IMagicEightBallService">
    <wsp:PolicyReference URI="#WSHttpBinding_TransportSecurity_IMagicEightBallService_policy"/>
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="GetAdvice">
      <soap12:operation soapAction="http://tempuri.org/IMagicEightBallService/GetAdvice" 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="MagicEightBallService">
    <wsdl:port name="WSHttpBinding_TransportSecurity_IMagicEightBallService" binding="tns:WSHttpBinding_TransportSecurity_IMagicEightBallService">
      <soap12:address location="https://localhost/MagicEightBall/MagicEightBallService.svc"/>
      <wsa10:EndpointReference>
        <wsa10:Address>
          https://localhost/MagicEightBall/MagicEightBallService.svc
        </wsa10:Address>
      </wsa10:EndpointReference>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

これをJavaから使用しようとすると、なぜエラーが発生するのですか?Axis2 / Javaを使用して使用しようとすると、次のエラーが発生します。

org.apache.axis2.AxisFault: Must Understand check failed for header http://www.w3.org/2005/08/addressing : Action

また、JAX-WSを使用しようとすると、次のエラーが発生します。

javax.xml.ws.soap.SOAPFaultException: MustUnderstand headers:[{http://www.w3.org/2005/08/addressing}Action] are not understood

これまでのところ、これらのいずれでも成功していません。サーバーとクライアントのどちらに修正を適用する必要があるのか​​わかりません。

(WCF Web.configを含む詳細については、私が投稿した関連質問を参照してください)。

4

5 に答える 5

4

ランニング:

ServiceClient sc = stub._getServiceClient();
sc.engageModule("addressing");

アドレス指定モジュールを使用して、この問題を修正します。

于 2011-07-27T19:13:12.903 に答える
3

投稿が古いことは知っていますが、誰かがまだこの問題に直面している可能性があります。

JAX-WSを使用していますが、同じ問題が発生していました。https://jax-ws.java.net/jax-ws-21-ea3/docs/wsaddressing.html#On_the_client_sideを読んだ後、私は自分に合った解決策を見つけました。

コードは次の行で壊れていました:

IFooService service = new FooService().getWSHttpBindingIFooService();

私がやったことは次のとおりです。

IFooService service = new FooService().getWSHttpBindingIFooService(new javax.xml.ws.soap.AddressingFeature());

それでおしまい。

于 2016-04-29T22:15:00.953 に答える
1

また、addressing.marとsoapmonitor.marをライブラリパスに追加します。

于 2011-08-02T03:34:44.660 に答える
1

私も同じ問題を抱えていました。

私の場合、WebサービスのWSDLは.netのWCFを使用して作成されており、JAVA側で使用しています。何度か試した後、対応するヘッダーがWebサービスにないことに気付きました。dotnetチームに-ポート名をWebサービスに追加するように依頼しました。このポート名はWebサービスの通常の名前です。これが必要だったのは、JAVA側では、実際にWebサービスにアクセスするためにポートタイプとポート名が必要だからです。

サービス内の.net側に以下の行を追加してから、JAVA側で消費してみてください。

[ServiceContract(Namespace = "BookStockWebService", Name = "BookStock")]
[ServiceBehavior(Namespace = "BookStockWebServiceport", Name = "BookStockPort")]
于 2014-01-29T04:08:11.360 に答える
0

クライアントがApacheCXFを使用して生成され、この問題に直面している場合は、以下が役立ちます。

  1. 以下の注釈をIServiceインターフェースに追加します。 @Addressing(enabled=true, required=false)

  2. 呼び出しのためにサービスが取得されているクライアントクラスでは、次のようになります。

ServiceImpl service = new ServiceImpl(wsdl,service); IService port = service.getWSHttpBindingIService(new AddressingFeature(true));

AddressingFeatureのインポートはjavax.xml.ws.soap.AddressingFeatureです。

于 2021-02-03T12:08:24.580 に答える