作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Apache cxf-codegen-plugin
用于尝试从 WSDL 文件生成 Java 类的 Maven 插件。我收到以下错误:
Part <parameters> in Message <{http://www.foo.com/bar}PushCommandSoapIn> referenced Type <{http://www.foo.com/bar}CommandMessage> can not be found in the schemas
有问题的类型 ( CommandMessage
) 在 XSD 文件中定义,我尝试使用以下 POM 文件引用该文件:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.11</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/SomeService.wsdl</wsdl>
<dependencies>
<!-- Here I try to reference the XSD -->
<dependency>${basedir}/src/main/resources/wsdl/SomeTypes.xsd</dependency>
</dependencies>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
关于我为什么会收到错误的任何建议?我不确定添加 <dependency>
是正确的方法,但我很难找到描述如何引用 XSD 文件的文档。
这是 WSDL 文件中引用缺失类型的片段:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:bar="http://www.foo.com/bar"
targetNamespace="http://www.foo.com/bar">
<wsdl:message name="PushCommandSoapIn">
<wsdl:part name="parameters" element="bar:CommandMessage" />
</wsdl:message>
这是 XSD 文件的 header 和片段:
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.foo.com/bar"
xmlns:bar="http://www.foo.com/bar"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd" />
...
<element name="CommandMessage" type="bar:CommandMessageType" substitutionGroup="bar:Message" final="#all" />
最佳答案
您的 wsdl 中需要一个 wsdl:types 元素,该元素具有一个包含导入的模式。基本上,wsdl 需要了解架构。
<wsdl:types>
<xsd:schema>
<xsd:import namespace="http://www.foo.com/bar" schemaLocation="bar.xsd"/>
</xsd:schema>
</wsdl:types>
关于java - 如何使用 Apache CXF Maven 插件链接到 XSD 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23391397/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!