javax.xml.ws.WebServiceException:方法X暴露为WebMethod,但是没有对应的wsdl操作

ake*_*rra 2 java soap wsdl web-services jax-ws

我正在使用 JAX-WS RI 与第三方 Web 服务 (Adyen) 集成。我已经下载了他们的 wsdl 副本,并jaxws:wsdl2java在我的构建中使用以生成 Web 服务实现源代码。在运行时,当我尝试通过调用我自动生成的支付服务类的 getPort() 方法来设置端口时,我收到以下异常,声称有一个公开的方法,但它不存在于 wsdl portType 元素中:

javax.xml.ws.WebServiceException: Method adjustAuthorisation is exposed as WebMethod, but there is no corresponding wsdl operation with name {http://payment.services.adyen.com}adjustAuthorisation in the wsdl:portType{http://payment.services.adyen.com}PaymentPortType
Run Code Online (Sandbox Code Playgroud)

但是,它存在于 portType 元素中。这是 wsdl 的相关片段:

javax.xml.ws.WebServiceException: Method adjustAuthorisation is exposed as WebMethod, but there is no corresponding wsdl operation with name {http://payment.services.adyen.com}adjustAuthorisation in the wsdl:portType{http://payment.services.adyen.com}PaymentPortType
Run Code Online (Sandbox Code Playgroud)

完整的 wsdl 可以在这里看到:https ://pal-live.adyen.com/pal/servlet/Payment/v30?wsdl

wsdl 包含在具有类路径 /wsdl/Payment.wsdl 的目标 jar 中。我在运行时使用配置类中的代码加载它:

<wsdl:portType name="PaymentPortType">
  <wsdl:operation name="adjustAuthorisation">
    <wsdl:input name="adjustAuthorisationRequest" message="tns:adjustAuthorisationRequest" />
    <wsdl:output name="adjustAuthorisationResponse" message="tns:adjustAuthorisationResponse" />
      <wsdl:fault name="ServiceException" message="tns:ServiceException" />
  </wsdl:operation>
  ...
</wsdl:portType>
Run Code Online (Sandbox Code Playgroud)

whereserviceUrl = "http://payment.services.adyen.com"serviceName = "Payment"which 与 wsdl 匹配。

最后,这是我尝试打开端口并最终得到异常的代码片段:

URL wsdl = getClass().getResource(wsdlLocation);
onlineService = new Payment(wsdl, new QName(serviceUrl, serviceName));
Run Code Online (Sandbox Code Playgroud)

为什么它似乎误读了 wsdl 的任何想法?另一个可能重要的信息是我最近更新了 wsdl,以前我的应用程序使用 Adyen 的 API 版本 12 和相应的 wsdl,现在我升级到版本 30。该应用程序以前使用相同的代码运行良好。

mce*_*nak 5

用于生成类的 wsdl 文件与运行时加载的 wsdl 文件不匹配。

  • 这些类是使用较新版本生成的,因为错误提到了 WebMethod adjustAuthorisation
  • 在运行时加载的 wsdl 是一个旧版本,它不包含该adjustAuthorization方法。

注意之间的区别v30v12在此处输入图片说明