java - Java 和 Soap Web 服务 | 为什么命名空间前缀在迁移时会自动从 ns2 更改为 ns4?
问题描述
Soap Service Migration 更改 Web 服务响应的命名空间前缀:
早些时候是:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<ns2:GetProjectsResponseType
xmlns="http://psi.eto.com/tsb/schema/common"
xmlns:ns2="http://tsb.eto.com/terp/ws/schema"
xmlns:ns3="http://psi.eto.com/tsb/schema/project"
xmlns:ns4="http://tsb.eto.com/tsb"
xmlns:ns5="http://psi.eto.com/tsb/schema/customer"
xmlns:ns6="http://psi.eto.com/tsb/schema/servicecontract"
xmlns:ns7="http://psi.eto.com/tsb/schema/task"
xmlns:ns8="http://psi.eto.com/tsb/schema/offering"
xmlns:ns9="http://psi.eto.com/kil/system/message">
现在它变为:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<ns2:GetProjectsResponseType
xmlns="http://psi.eto.com/tsb/schema/common"
xmlns:ns2="http://tsb.eto.com/terp/ws/schema"
xmlns:ns3="http://psi.eto.com/tsb/schema/servicecontract" <------
xmlns:ns4="http://tsb.eto.com/tsb"
xmlns:ns5="http://psi.eto.com/tsb/schema/customer"
xmlns:ns6="http://psi.eto.com/tsb/schema/project" <-----
xmlns:ns7="http://psi.eto.com/tsb/schema/task"
xmlns:ns8="http://psi.eto.com/tsb/schema/offering"
xmlns:ns9="http://psi.eto.com/kil/system/message">
这个命名空间发生变化的原因可能是什么?
@WebService(targetNamespace = "http://tsb.eto.com/terp/ws/v2", name = "Terp-v2")
@XmlSeeAlso({com.eto.psi.tsb.schema.common.ObjectFactory.class,
com.eto.psi.tsb.schema.offering.ObjectFactory.class,
com.eto.psi.kil.system.message.ObjectFactory.class,
com.eto.tsb.terp.ws.schema.ObjectFactory.class,
com.eto.psi.tsb.schema.task.ObjectFactory.class,
com.eto.psi.tsb.schema.servicecontract.ObjectFactory.class,
com.eto.psi.tsb.schema.project.ObjectFactory.class,
com.eto.tsb.tsb.ObjectFactory.class,
com.eto.psi.tsb.schema.customer.ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface TerpV2 {
@WebMethod(operationName = "GetServiceContracts")
@WebResult(name = "GetServiceContractsResponseType", targetNamespace = "http://tsb.eto.com/terp/ws/schema", partName = "payload")
public com.eto.tsb.terp.ws.schema.GetServiceContractsResponseType getServiceContracts(
@WebParam(partName = "payload", name = "GetServiceContractsType", targetNamespace = "http://tsb.eto.com/terp/ws/schema")
com.eto.tsb.terp.ws.schema.GetServiceContractsType payload
) throws TerpServiceFault;
and so on all operations are defined (without above sequence)
包信息对所有 ns 都有类似的内容:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://psi.eto.com/tsb/schema/servicecontract", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.eto.psi.tsb.schema.servicecontract;
没有这样的命名空间和操作名称映射列表。尝试删除 Xmlnsfor 合格但没有理想的结果。
原因:客户的旧代码尚未准备好更改和硬编码命名空间。
解决方案
您可能可以使用 Package Info 来完全修复命名空间映射:
@javax.xml.bind.annotation.XmlSchema(
namespace = "http://psi.eto.com/tsb/schema/servicecontract",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
xmlns = {
@javax.xml.bind.annotation.XmlNs(prefix = "ns2",
namespaceURI="http://tsb.eto.com/terp/ws/schema"),
@javax.xml.bind.annotation.XmlNs(prefix="ns3",
namespaceURI="http://psi.eto.com/tsb/schema/project")
// include the remaining namespace declarations
)
)
package com.eto.psi.tsb.schema.servicecontract;
来源:JavaDoc forXmlSchema
,示例 2。
请注意,这仅在所有消息都具有完全相同的名称空间映射时才有效。
恕我直言,这应该只是一种解决方法。您应该敦促您的客户尽快调整适当的命名空间处理。
推荐阅读
- django - __init__() 缺少 1 个必需的位置参数:'model_field'
- node.js - Docker 中的 Nuxt.js:缺少依赖项
- android - android:在whatsapp上聊天时调用内容观察者onchange方法
- gensim - gensim 的 fasttext 的默认设置是什么?
- java - IOS 能力配置。未找到 InputStream 和 long 或无法访问
- javascript - TypeError:无法读取未定义的属性“brewery_type”
- apache-spark - 没有看到 spark-submit 的输出
- reactjs - React 路由器不适用于组件
- php - 您将如何托管仅适用于少数用户的私有 Web 应用程序?
- http - -d 在 curl 请求中代表什么?