gpt4 book ai didi

java - 从 wsdl 生成 java 类

转载 作者:行者123 更新时间:2023-12-02 07:33:21 24 4
gpt4 key购买 nike

我有一个 wsdl,我使用 apache cxf 从它生成服务器 stub 。问题是我部署的新 wsdl 与最初的 wsdl 不同,因此旧 wsdl 的 SOAP 请求不适用于新 wsdl。我用soapUI测试它。新的有这个奇怪的命名空间init:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:init="http://initiator.clientprovisioning_1_0.mdm.smarttrust.com/">
<soapenv:Header/>
<soapenv:Body>
<init:cpDiscovery.Response>

旧 SOAP 消息没有这个:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<cpDiscovery.Response>

我将提供所需的任何附加信息。我已经尝试解决这个问题两天了。请帮忙。

编辑这个 init 前缀取决于 java 包的第一个字母。例如,如果类在 me.mycompany.example 中,前缀是:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:exam="http://example.mycompany.net/">
<soapenv:Header/>
<soapenv:Body>
<exam:cpDiscovery.Response>

编辑 http://cxf.apache.org/docs/developing-a-service.html#DevelopingaService-AnnotatingtheCode这表明

targetNamespace property Specifies the target namespace under which the service is defined. If this property is not specified, the target namespace is derived from the package name.

我该如何摆脱这个?

最佳答案

“旧的” SOAP 消息实际上是无效的,并且可能根本不应该起作用。根据soap 规范,soap:Body 的子级必须是命名空间限定的。看来"new"行为正是您想要的。

关于java - 从 wsdl 生成 java 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12642119/

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