标签: wsdl2java

wsdl2java两个类具有相同的XML类型名称"{http://***.***.$.**/*/////*}} objectFactory"

在旧版本4.5.2中使用cxf 2.6.8的较新版本的servicemix(在5.4 - cxf 3.0.2和5.3 - cxf 2.7.11上测试)中出现此问题,一切正常,Web服务已创建.

在我们的项目中,我们有很多不同的web服务由maven插件wsdl2java在不同的包中生成.在servicemix 5.4中,几乎所有的web服务都由于这些错误而中断,奇怪的是在之前的servicemix 5.3中,bundle之一能够在没有任何项目修改的情况下启动.

在maven我尝试使用额外的extraarg:

<extraarg>-autoNameResolution</extraarg>
<extraarg>-xjc-npa</extraarg>
Run Code Online (Sandbox Code Playgroud)

但没有任何结果

堆栈跟踪:

Unable to start blueprint container for bundle bundle-name1
    org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to initialize bean .camelBlueprint.factory.camelContext
        at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:714)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[19:org.apache.aries.blueprint.core:1.4.1]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_21]
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_21]
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:753)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.camel.blueprint.handler.CamelNamespaceHandler$CamelDependenciesFinder.process(CamelNamespaceHandler.java:863)[105:org.apache.camel.camel-blueprint:2.13.2]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.processProcessors(BlueprintContainerImpl.java:528)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:361)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:245)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:235)[19:org.apache.aries.blueprint.core:1.4.1]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[14:org.apache.aries.util:1.1.0]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[14:org.apache.aries.util:1.1.0]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[14:org.apache.aries.util:1.1.0]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[14:org.apache.aries.util:1.1.0]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[14:org.apache.aries.util:1.1.0]
        at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1127)[org.apache.felix.framework-4.4.1.jar:]
        at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)[org.apache.felix.framework-4.4.1.jar:] …
Run Code Online (Sandbox Code Playgroud)

java wsdl cxf wsdl2java apache-servicemix

9
推荐指数
2
解决办法
2863
查看次数

如何使用Apache Axis2和WSDL2Java向SOAP响应添加命名空间引用

我正在查看我正在开发的Web服务的SOAP输出,我发现了一些好奇的东西:

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Body>
      <ns1:CreateEntityTypesResponse xmlns:ns1="http://somedomain.com/wsinterface">
         <newKeys>
            <value>1234</value>
         </newKeys>
         <newKeys>
            <value>2345</value>
         </newKeys>
         <newKeys>
            <value>3456</value>
         </newKeys>
         <newKeys xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
         <newKeys xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
         <errors>Error1</errors>
         <errors>Error2</errors>
      </ns1:CreateEntityTypesResponse>
   </soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)

我有两个newKeys元素是nil,两个元素都插入了xsi的命名空间引用.我想在soapenv:Envelope元素中包含该命名空间,以便命名空间引用只发送一次.

我使用WSDL2Java生成服务框架,因此我无法直接访问Axis2 API.

java soap axis2 namespaces wsdl2java

8
推荐指数
1
解决办法
2万
查看次数

两个类具有相同的xml类型名称

当我尝试在RAD中发布我的工作区时,我收到此错误"两个类具有相同的xml类型名称",可能是因为相同的类名存在于同一个包中,但存在于两个不同的jar中.并且看起来@XmlType注释需要在这些类的源中具有其属性名称和命名空间的不同值.我尝试在Apache CXF中使用wsdl2java,但我无法使其生成此命名空间属性.我试图摆弄-p package选项,但这仅用于将生成的源放在指定的包中.

有关如何为wsdl中遇到的每个元素生成此命名空间属性的任何想法?TIA.

wsdl cxf wsdl2java jaxb xmltype

8
推荐指数
1
解决办法
1万
查看次数

发布Web服务时出错

我有一个WSDL文件,我从中创建了Server Side Code Skeleton.现在修改了这些骨架Java类后,我从项目文件夹中删除了WSDL文件.现在,我正在尝试为这些类准备Web服务.我使用Axis引擎和apache tomcat 5.5来嵌入eclipse.但是当我开始这个时,我得到以下错误.

IWAB0489E将Web服务部署到Axis运行时axis-admin失败时出现错误{http://schemas.xmlsoap.org/soap/envelope/}Server.userException java.lang.reflect.InvocationTargetException

任何人都可以帮忙.这个错误是什么?

java axis web-services wsdl2java

8
推荐指数
1
解决办法
1681
查看次数

Microsoft Web服务和CXF客户端:JAXB无法理解"s:schema"

我有普通的Microsoft Web服务和普通的最新版本的CXF和Java/JDK 1.6,Eclipse等.当我运行wsdl2java时,JAXB部分抛出一个错误"由JAXB引发:未定义的元素声明:schema'"

wsdl的部分导致它看起来像:

<s:element name="GetDepartmentsResponse">
 <s:complexType>
  <s:sequence>
   <s:element minOccurs="0" maxOccurs="1" name="GetDepartmentsResult">
    <s:complexType>
     <s:sequence>
      <s:element ref="s:schema" /> 
      <s:any /> 
     </s:sequence>
    </s:complexType>
   </s:element>
  </s:sequence>
 </s:complexType>
</s:element>
Run Code Online (Sandbox Code Playgroud)

我可以<s:element ref="s:schema" />随处删除 并保留<s:any/>吗?它似乎是Java < - > Microsoft Web服务不可侵犯性的常见障碍.但我找不到CXF的任何解决方法.

谢谢

xsd wsdl web-services cxf wsdl2java

8
推荐指数
1
解决办法
3355
查看次数

CXF:在同一个soap:adress上实现多个端口?

我们从客户端获得了WSDL,要求我们在我们这边实施服务.

WSDL包含3个端口绑定,具有不同的名称和绑定,但相同<soap:adress>- 如下所示:

<port name="Name1" binding="tns:Binding1">
    <soap:address location="http://localhost/Service/ServicePort" />
</port>
<port name="Name2" binding="tns:Binding2">
    <soap:address location="http://localhost/Service/ServicePort" />
</port>
<port name="Name3" binding="tns:Binding3">
    <soap:address location="http://localhost/Service/ServicePort" />
</port>
Run Code Online (Sandbox Code Playgroud)

这样的WSDL是否可以用CXF实现?

当我运行wsdl2java时,CXF会生成3个java接口.

我首先尝试了一个类实现类

class MyServiceClass implements Interface1, Interface2, Interface3 {...}
Run Code Online (Sandbox Code Playgroud)

但是当我部署它并使用SoapUI检查时,出于某种原因,它只会暴露端口绑定Interface1,并且似乎忽略了其他2个.为什么?

然后我试着实现3个不同的ServiceClasses(每个实现一个接口),然后在cxf-config.xml中放入多个<jaxws:endpoint>具有相同address属性的ServiceClasses

但是我得到了部署错误:

RuntimeException: Soap 1.1 endpoint already registered on address /Address
Run Code Online (Sandbox Code Playgroud)

任何提示,如何在CXF中实现这样的WSDL?可能吗?

soap wsdl cxf wsdl2java jax-ws

8
推荐指数
1
解决办法
4220
查看次数

如何使用wsdl2java为wsdl生成SOAP 1.2绑定?

我简要说明:

如何让wsdl2java生成SOAP 1.2绑定?

详细说明:

我使用工具(apache cxf 3.0.2)为wsdl生成了java服务类wsdl2java:

MBA-Anton:bin asmirnov$ ./wsdl2java -server -catalog /tmp/wsdl/catalog  -d /tmp/onvif/server http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl
Run Code Online (Sandbox Code Playgroud)

然后我创建了服务代码并运行它,它正在运行:

public static void main(String args[]) throws InterruptedException {
        System.out.println("Starting Server");
        Endpoint.publish("udp://239.255.255.250:3702", new DiscoveryService());

        System.out.println("Server ready...");

        Thread.sleep(10 * 60 * 1000); // 10 min
        System.out.println("Server exiting");
        System.exit(0);
    }
Run Code Online (Sandbox Code Playgroud)

开始记录:

Starting Server
28.11.2014 19:51:59 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://www.onvif.org/ver10/network/wsdl}DiscoveryService from class org.onvif.ver10.network.wsdl.DiscoveryLookupPort
28.11.2014 19:52:00 org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be udp://239.255.255.250:3702
28.11.2014 19:52:00 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: …
Run Code Online (Sandbox Code Playgroud)

xml wsdl cxf wsdl2java ws-discovery

8
推荐指数
0
解决办法
3181
查看次数

wsdl:如何使用errorCode和errorMessage内联生成异常?

我正在尝试使用wsdl:fault,但无法生成预期的java类(异常).我生成的类(删除了注释和getter/setter):

public class ProjectException extends Exception {
    private com.home.project.generated.Fault fault;
}

public class Fault {
    protected String errorMessage;
    protected long errorCode;
}
Run Code Online (Sandbox Code Playgroud)

我希望生成的类:

public class ProjectException extends Exception {
    protected String errorMessage;
    protected long errorCode;
}
Run Code Online (Sandbox Code Playgroud)

我的wsdl:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="ProjectSoapServiceImplService"
                  targetNamespace="http://www.home.com/webservices/v1_0/project/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:tns="http://www.home.com/webservices/v1_0/project/"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
    <wsdl:types>
        <xs:schema xmlns:tns="http://www.home.com/webservices/v1_0/project/"
                   xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified"
                   targetNamespace="http://www.home.com/webservices/v1_0/project/" version="1.0">

            <xs:element name="createProject" type="tns:projectRequest"/>
            <xs:element name="projectResponse" type="tns:projectResponse"/>

            <xs:complexType name="projectRequest">
                <xs:sequence>
                    <xs:element minOccurs="0" name="projectName" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="projectResponse">
                <xs:sequence>
                    <xs:element minOccurs="0" name="projectId" type="xs:long"/>
                </xs:sequence>
            </xs:complexType>
            <xs:element …
Run Code Online (Sandbox Code Playgroud)

java xsd wsdl web-services wsdl2java

8
推荐指数
1
解决办法
2005
查看次数

在 gradle 中添加 apche cxf-bundle 作为依赖项时出现“不支持:http://javax.xml.XMLConstants/property/accessExternalDTD 异常”

尝试在我的应用程序中添加 apache-cxf 包。但是在运行应用程序时出现以下错误无法实例化 [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping]:工厂方法“payloadRootAnnotationMethodEndpointMapping”抛出异常;嵌套异常是 java.lang.ExceptionInInitializerError

这是由引起的:java.lang.IllegalArgumentException:不支持:http://javax.xml.XMLConstants/property/accessExternalDTD

尝试在任务中添加以下属性

wsdl2java {
 System.setProperty('javax.xml.accessExternalSchema', 'all')
 System.setProperty('javax.xml.accessExternalDTD','all')
 generatedWsdlDir = file("src/main/generated-sources/")  // target directory for generated source code
 wsdlsToGenerate = [   //  2d-array of wsdls and cxf-parameters
                      ['src/main/resources/xsd/wsdl/***.wsdl'],
]
Run Code Online (Sandbox Code Playgroud)

}

added the dependency as 
compile group: 'org.apache.cxf', name: 'cxf-bundle', version: '2.4.2'
Run Code Online (Sandbox Code Playgroud)

出现以下错误

Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping]: Factory method 'payloadRootAnnotationMethodEndpointMapping' threw exception; nested exception is java.lang.ExceptionInInitializerError

Caused by: java.lang.IllegalArgumentException: Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD
    at org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:576) ~[xalan-2.7.1.jar:?]
Run Code Online (Sandbox Code Playgroud)

java wsdl2java build.gradle

8
推荐指数
1
解决办法
1万
查看次数

Java 11:导入 javax.xml.ws.WebFault:“无法解析符号 ws”

我正在尝试将服务升级到 Java 11。

我们目前使用 wsdl2java (Apache CXF) 来生成基于 WSDL 的源代码。我正在通过 Maven 完成这一切。源文件根据 wsdl 正确生成。

不幸的是,生成的一些源文件包括以下导入:

import javax.xml.ws.WebFault; 
import javax.jws.WebService;
Run Code Online (Sandbox Code Playgroud)

我缺少包 javax.xml.ws 和 javax.jws。

在我的研究中,我发现 Jaxb 从主 JDK 中被弃用,因此我需要在我的 pom.xml 文件中添加新的依赖项。我尝试了各种组合,但它们都归结为:

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.3.0.1</version>
    </dependency>

    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.3.2</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

不幸的是,无论我做什么,我的 IDE 似乎都找不到 javax.xml.ws 和 javax.jws。

有谁知道我可能需要包含哪些依赖项才能获得这些包?

虽然它不是问题的核心,但这是我的 wsdl2java 内容:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.3.2</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated-sources/cxf/</sourceRoot>

                <wsdlRoot>src/main/webapp/resources/wsdl/fedex</wsdlRoot>
                <includes>
                    <include>**/*.wsdl</include>
                </includes>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions> …
Run Code Online (Sandbox Code Playgroud)

java wsdl wsdl2java jaxb java-11

7
推荐指数
1
解决办法
7313
查看次数