gpt4 book ai didi

javax.xml.ws.WebServiceException : Method X is exposed as WebMethod, 但是没有对应的wsdl操作

转载 作者:行者123 更新时间:2023-12-02 16:28:54 25 4
gpt4 key购买 nike

我正在使用 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

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

<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>

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

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

URL wsdl = getClass().getResource(wsdlLocation);
onlineService = new Payment(wsdl, new QName(serviceUrl, serviceName));

其中 serviceUrl = "http://payment.services.adyen.com"serviceName = "Payment" 匹配 wsdl。

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

ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try
{
port = config.getOnlineService().getPaymentHttpPort(); // exception thrown here
}
finally
{
Thread.currentThread().setContextClassLoader(oldClassLoader);
}

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

最佳答案

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

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

注意 v30v12 的区别: enter image description here

关于javax.xml.ws.WebServiceException : Method X is exposed as WebMethod, 但是没有对应的wsdl操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63850416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com