标签: wsdl2java

Scala相当于wsdl2java?

是否与wsdl2java等效,它将获取WSDL文件并为服务器和/或客户端生成scala存根?

我用谷歌搜索,但要么没有,要么我的谷歌弱.

web-services scala wsdl2java

13
推荐指数
1
解决办法
3908
查看次数

列表中的Cxf Wsdl2java null条目消失

我用cxf创建了一个带有xew插件的web服务客户端,用于列表展开

问题是null列表中的内容消失了.例如:

我有一个List<String>带有字符串和null-entry的请求

当请求现在到达服务器时,它只包含字符串而不是null条目.因此示例列表中只有2个条目.

这里是wsdl的一个例子:

[..]
<!-- the request -->
<xsd:element name="createGroup">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string"/>
            <xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="ns2:ArrayOfRole"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
[..]
<!-- the list which will be unwrapped -->
<xsd:complexType name="ArrayOfRole">
    <xsd:sequence>
        <xsd:element maxOccurs="unbounded" minOccurs="0" name="Role" nillable="true" type="xsd:String"/>
    </xsd:sequence>
</xsd:complexType>
Run Code Online (Sandbox Code Playgroud)

我正在使用maven来生成ws客户端

<properties>
    <cxf.version>3.0.5</cxf.version>
    <jaxbBasic.version>0.6.5</jaxbBasic.version>
</properties>
[..]
<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>src/main/java</sourceRoot>
                <defaultOptions>
                    <bindingFiles>
                        <bindingFile>${basedir}/jaxbBindings.xml</bindingFile>
                        <bindingFile>${basedir}/jaxwsBindings.xml</bindingFile>
                    </bindingFiles> …
Run Code Online (Sandbox Code Playgroud)

cxf wsdl2java jax-ws jaxb jaxb-xew-plugin

12
推荐指数
1
解决办法
923
查看次数

Axis2的wsdl2java在RPC /编码样式的Web服务上失败

Axis2还有其他选择吗?或者让它工作的方式(例如,不同的数据绑定)?

Retrieving document at '...'.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
        at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
        at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:53)
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224)
        ... 2 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:50)
        ... 3 more
Caused by: org.apache.axis2.schema.SchemaCompilationException: can not find type {http://schemas.xmlsoap.org/soap/encoding/}Array from the parent schema ...        at org.apache.axis2.schema.SchemaCompiler.copyMetaInfoHierarchy(SchemaCompiler.java:1296)
        at org.apache.axis2.schema.SchemaCompiler.processComplexContent(SchemaCompiler.java:1258)
        at org.apache.axis2.schema.SchemaCompiler.processContentModel(SchemaCompiler.java:1153)
        at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1097)
        at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1017)
        at org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.java:931)
        at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:766)
        at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:552)
        at org.apache.axis2.schema.SchemaCompiler.process(SchemaCompiler.java:1991)
        at org.apache.axis2.schema.SchemaCompiler.processParticle(SchemaCompiler.java:1874)
        at …
Run Code Online (Sandbox Code Playgroud)

java axis axis2 wsdl2java jax-rpc

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

在CXF wsdl2java中设置Java合规性级别

我是CXF的新手,我正在尝试从WSDL创建一个客户端.我过去使用过Metro和Axis.我下载了apache-cxf-2.3.3并使用wsdl2java生成客户端存根.我使用Maven并用它来设置我的pom:

<properties>
    <cxf.version>2.3.3</cxf.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-security</artifactId>
        <version>${cxf.version}</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <optimize>true</optimize>
                <debug>true</debug>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

当我构建项目时,我得到以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project client-cxf: Compilation failure: Compilation failure:
[ERROR] \Devel\Projects\Client-CXF\src\main\java\my\webservice\ServiceRuntimeException.java:[38,149] cannot find symbol
[ERROR] symbol  : method required()
Run Code Online (Sandbox Code Playgroud)

[ERROR] \Devel\Projects\Client-CXF\src\main\java\my\snmpv2\MyService.java:[76,8] cannot find symbol
[ERROR] symbol  : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
[ERROR] location: class javax.xml.ws.Service
Run Code Online (Sandbox Code Playgroud)

似乎问题与生成的代码使用Java 6特性(XmlElementRef的"require"元素,Service的新构造函数)这一事实有关,但CXF Maven依赖关系是针对Java 5的. …

java cxf wsdl2java

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

"无法初始化默认的wsdl ......" - 为什么?

pom.xml包含以下内容,为具有下面指定的WSDL的工作Web服务自动生成客户端:

        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>2.3.1</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <configuration>
                        <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/wsdl/myclient.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-client</extraarg>
                                    <extraarg>-verbose</extraarg>
                                </extraargs>
                                <wsdlLocation>wsdl/myclient.wsdl</wsdlLocation>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

项目构建正常,没有任何错误或警告,我可以在文件夹myclient.wsdl下的JAR文件中看到该wsdl文件.

但是当我尝试运行那个JAR时:

  java -Xmx1028m -jar myclient-jar-with-dependencies.jar
Run Code Online (Sandbox Code Playgroud)

它抱怨"无法从wsdl/myclient.wsdl初始化默认的wsdl"

为什么?

我错过了什么?

我如何找出什么路径wsdl/myclient.wsdl在pom.xml中转化为,使客户的JAR抱怨在运行时?

更新:我知道一些涉及修改自动生成代码的解决方案/解决方法:

  1. 为wsdl URL传递"null",然后使用((BindingProvider)端口).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY," http://example.com/ ....")来设置地址.
  2. 将WSDL作为Java资源加载并将其位置传递到服务的构造函数中.

但是我更感兴趣的是一个解决方案,需要输入正确的值pom.xml类似于类路径方法(但遗憾的是,由于某种原因,类路径不适合我).

相反,我应该在那里打字的任何想法?显然,这是一个非常简单的例子,可以找出该特定插件的正确路径规则,但我遗漏了一些东西而且我不知道它是什么.

wsdl cxf wsdl2java pom.xml

10
推荐指数
2
解决办法
5993
查看次数

关于SOAP请求客户端的wsimport vs wsld2java

我刚刚使用wdmport的jdk1.7生成了java源文件来构建Web服务客户端.

wsimport -keep /path/to/wsdl
Run Code Online (Sandbox Code Playgroud)

为了生成SOAP请求,我在生成的文件夹下使用了clasess.一切顺利,回复200 :)

但是,我想使用(为......'有趣')CXF(v.2.7)wsdl2java工具使其完全相同,但使用此工具它不会生成SOAP请求所需的类,它不会t创建生成的文件夹.

wsdl2java -keep -verbose /path/to/wsdl
Run Code Online (Sandbox Code Playgroud)

另外我注意到工具自己创建的类ObjectFactory是不同的.使用wsdl2java创建一个很短的文件.

那么,为什么这些工具会产生不同的结果?

我不明白这两者的区别,你能帮帮我吗?

使用的WSDL导入XSD文件,这有一个众所周知的问题,我已经解决了感谢这个博客条目 这里

感谢您的回答

soap web-services cxf wsdl2java wsimport

10
推荐指数
0
解决办法
2780
查看次数

java.lang.ClassNotFoundException: com.sun.org.apache.xml.internal.resolver.CatalogManager Java 11

我有一个JavaFX要从 迁移Java 8到的应用程序Java 11,这是一个粗略的过渡,但除了 之外,大多数应用程序都在工作web service,它一直给我一个例外:

Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
            at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
            at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
            at java.base/java.lang.Thread.run(Thread.java:834)
    Caused by: java.lang.NoClassDefFoundError: com/sun/org/apache/xml/internal/resolver/CatalogManager
            at com.sun.xml.ws.util.xml.XmlUtil.createDefaultCatalogResolver(XmlUtil.java:296)
            at com.sun.xml.ws.client.WSServiceDelegate.createCatalogResolver(WSServiceDelegate.java:348)
            at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:334)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:292)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:201)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:182)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:178)
            at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:89)
            at javax.xml.ws.Service.<init>(Service.java:82)
            at e.bop.asycuda.WSMrrtService.<init>(WSMrrtService.java:39)
            at e.bop.main.EBop.start(EBop.java:56)
            at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
            at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
            at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
            at java.base/java.security.AccessController.doPrivileged(Native Method)
            at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
            at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
            at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
            at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
            ... 1 more
    Caused by: java.lang.ClassNotFoundException: …
Run Code Online (Sandbox Code Playgroud)

java wsdl wsdl2java java-11

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

如何让 cxf-codegen-plugin 从 jakarta.xml.ws 生成 Web 服务?

从 Java 8 迁移到 Java 11。

将 cxf-codegen-plugin 从版本 3.2.0 更新到 3.3.6。

插件仍然使用 javax.jws.* 中的包(而不是 jakarta.jws.* 中的包)从 wsdl 文件生成 Java 存根:

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

/**
 * This class was generated by Apache CXF 3.3.6
 * 2020-08-12T19:22:40.406+02:00
 * Generated source version: 3.3.6
 *
 */
Run Code Online (Sandbox Code Playgroud)

我是否误认为 javax.jws 已弃用,应该更改为 jakarta.jws?

如何使用所需的包完成代码生成?

java wsdl2java cxf-codegen-plugin java-11

10
推荐指数
2
解决办法
7106
查看次数

更改生成的jaxb类的包

我在wsdl中定义了以下数据类型:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="myService" targetNamespace="http://example.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://example.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
    <wsdl:types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="example.com" targetNamespace="example.com" version="1.0">
            <xs:simpleType name="MyEnum">
                <xs:restriction base="xs:string">
                    <xs:enumeration value="one"/>
                    <xs:enumeration value="two"/>
                </xs:restriction>
            </xs:simpleType>
            <!-- SNIP other data types -->
        </xs:schema>
    </wsdl:types>
</wsdl:definitions>
Run Code Online (Sandbox Code Playgroud)

我希望MyEnum落入自己的包中.所以,我使用了一个jaxws绑定文件,并使用XPATH遍历模式和jaxb绑定来设置包,如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxws:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://java.sun.com/xml/ns/jaxws">
    <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='example.com']">
      <jxb:schemaBindings>
          <jxb:package name="abra.ca.dabra" /> <!-- this works, and changes package of all classes in the namespace-->
      </jxb:schemaBindings>
      <jxb:bindings node="//xs:simpleType[@name='MyEnum']">
          <jxb:package name="a.b.c"/> <!-- this does not work -->
      </jxb:bindings>
    </jaxws:bindings>
    <!-- SNIP - …
Run Code Online (Sandbox Code Playgroud)

java cxf wsdl2java jax-ws jaxb

9
推荐指数
1
解决办法
9973
查看次数

是否可以检索XML命名空间名称URI?

我的WSDL上有以下标记:

<?xml version='1.0' encoding='UTF-8'?>
<definitions name="" targetNamespace="http://xxxxx/ws"
             xmlns="http://schemas.xmlsoap.org/wsdl/"
             xmlns:s0="http://xxxxx/ws"
             xmlns:s1="http://schemas.xmlsoap.org/wsdl/soap/">
  <types>
    <xsd:schema attributeFormDefault="qualified" 
                elementFormDefault="qualified"
                targetNamespace="http://xxxxx/ws/comments" 
                xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
                xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
                xmlns:s0="http://xxxxx/ws" 
                xmlns:s1="http://schemas.xmlsoap.org/wsdl/soap/" 
                xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
                xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
                xmlns:tns="http://xxxxx/ws" 
                xmlns:tnsc="http://xxxxx/ws/comments" 
                xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                xmlns:y="http://new.webservice.namespace">
Run Code Online (Sandbox Code Playgroud)

此后,类型被限定为s0,s1 ...名称空间中的类型.

问题是命名空间端点(="http:// xxxxx/ws")是否需要是有效的URL?
如果端点不再存在 - 是否意味着我们需要再次为Web服务重新生成存根代理?

注意:Web Service本身的端点与命名空间的端点不同,但仍然存在.

xsd wsdl web-services wsdl2java

9
推荐指数
1
解决办法
4284
查看次数