简体   繁体   English

从wsdl生成java类

[英]Generating java classes from wsdl

I have an wsdl, from it i generated server stubs using apache cxf. 我有一个wsdl,从它我使用apache cxf生成服务器存根。 The problem is new wsdl which i deploy differs from initial one, so soap requests for old one do not work for the new one. 问题是我部署的新wsdl与初始版本不同,因此对旧版本的SOAP请求不适用于新版本。 I test it using soapUI. 我用soapUI测试它。 New ones have this weird namespace init : 新的有这个奇怪的命名空间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>

Old soap messages didnt had this: 老肥皂消息没有这个:

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

I'll provide whatever additional info is needed. 我将提供所需的任何其他信息。 I've been trying to solve this for 2 days now. 我一直试图解决这个问题2天了。 Please help. 请帮忙。

EDIT this init prefix depends on first letters the java package. 编辑这个init前缀取决于java包的第一个字母。 So for example if classes are in me.mycompany.example prefix is: 因此,例如,如果类在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>

EDIT http://cxf.apache.org/docs/developing-a-service.html#DevelopingaService-AnnotatingtheCode this states 编辑 http://cxf.apache.org/docs/developing-a-service.html#DevelopingaService-AnnotatingtheCode this states

targetNamespace property Specifies the target namespace under which the service is defined. targetNamespace属性指定定义服务的目标命名空间。 If this property is not specified, the target namespace is derived from the package name. 如果未指定此属性,则从包名称派生目标命名空间。

how do i get rid of this? 我怎么摆脱这个?

You've introduced a namespace into the XML schema that describes your SOAP payload. 您已在XML模式中引入了一个描述SOAP负载的命名空间。 This shouldn't affect a client's ability to invoke your service, as long as they can access the schema file. 这不应影响客户端调用服务的能力,只要他们可以访问模式文件即可。

The "old" soap message is actually invalid and likely should have never worked. “旧的”肥皂消息实际上是无效的,可能应该从未起作用。 Per the soap spec, children of the soap:Body MUST be namespace qualified. 根据soap规范,soap的子项:Body必须是名称空间限定的。 It looks like the "new" behavior is the one you want. 看起来“新”行为就是你想要的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM