标签: wsdl2java

javax.xml.ws.WebServiceException:未找到端口{http://tempuri.org/}WSHttpBinding_IDWService

我正在尝试在java中使用web服务,使用wsdl文件生成的客户端和wsdl2java.

我正在使用Eclipse版本的Helios和jdk 1.6.0_20,并且我使用wsld2java生成了.class文件,其中包含以下选项:

"-dc:\ WebServices\Generated -client -verbose -compile -autoNameResolution -p org.dwservice -sn DWService -wsdlLocation /WEB-INF/wsdl/DWService.wsdl c:\ WebServices\DWService.wsdl"

我将生成的文件打包成.jar并将其添加到我编译好的项目中.但是当我尝试使用webservice时,我得到了例外:

javax.xml.ws.WebServiceException: Port {http://tempuri.org/}WSHttpBinding_IDWService not found.
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:311)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:302)
at javax.xml.ws.Service.getPort(Service.java:92)
at org.dwservice.DWService.getWSHttpBindingIDWService(DWService.java:63)
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

import org.dwservice.*;
...

private DWService dwService = new DWService();
private IDWService iDWService = ***dwService.getWSHttpBindingIDWService()***;
Run Code Online (Sandbox Code Playgroud)

任何想法都将非常感激.

web-services wsdl2java jax-ws

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

在为Maven使用cxf-codegen-plugin时,ApacheCXF能否生成完整的构造函数?

我使用maven的cxf-codegen-plugin从我的wsdl/xsd生成服务器/客户端.创建的所有类型都有默认的no-arg-constructors,这使得它们很难处理.

有没有办法让Apache CXF生成一个完整的构造函数,并将该类的所有成员作为参数?

constructor cxf wsdl2java maven

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

Eclipse Indigo是否有任何Apache Axis WSDL2Java jar文件

Eclipse Indigo版本是否有单独的org.apache.axis.wsdl2java jar文件,因为它在indigo版本中不起作用,显示如下错误:

无法启动所选向导.插件"org.apache.axis.wsdl2java.eclipse"无法实例化类"org.apache.axis.wsdl2java.eclipse.wizards.WebReferenceImportWizard".组织/蚀/型芯/内部/ utils的/断言

但是这个jar文件在Eclipse sdk 2.1版本中运行,那么我该如何进行转换呢?

谢谢,@ nag.

eclipse wsdl2java

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

未定义的元素声明'xs:schema'

我是网络服务的新手.

我必须为Web服务编写rest Web服务客户端.Web服务在SoapUI上运行正常.URL的WSDL文件提供给我.但是当我在Eclipse项目中添加wsdl文件时,它会产生编译错误

src-resolve.4.2: Error resolving component 'xs:schema'. It was detected that 'xs:schema' is in namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document 'file:///E:/Ashish%20Workspace/HATStoLSAMS%20Webservice/HATS2LSAMSWS/WebContent/WEB-INF/wsdl/CorpsiteService.svc.wsdl'. If this is the incorrect namespace, perhaps the prefix of 'xs:schema' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///E:/Ashish%20Workspace/HATStoLSAMS%20Webservice/HATS2LSAMSWS/WebContent/WEB-INF/wsdl/CorpsiteService.svc.wsdl'.
Run Code Online (Sandbox Code Playgroud)

我搜索了很多东西以摆脱这些错误,但没有任何效果.如果我忽略错误并尝试使用wsimport和wsdl2java命令创建存根,则会出错

[ERROR] undefined element declaration 'xs:schema'
line 1 of http://chec.local/STAR.WCF/CorpsiteService.svc?singlewsdl
Run Code Online (Sandbox Code Playgroud)

我使用下面的命令来生成存根

wsimport -d e:\test -s E:\wssrc http://chec.local/STAR.WCF/CorpsiteService.svc?singlewsdl -wsdllocation "../../../../../WEB-INF/wsdl/CorpsiteService.svc.wsdl"
Run Code Online (Sandbox Code Playgroud)

我在这一点上陷入困​​境,并且整天都在努力.任何有关这方面的帮助都会非常有帮助

java wsdl web-services wsdl2java wsimport

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

CXF wsdl2java没有为成员生成Javadoc

wsdl2java从CXF 2.7.5开始运行

<xsd:complexType name="baseTaxParametersEnhanced">
  <xsd:annotation>
    <xsd:documentation>
      Some type comment.
    </xsd:documentation>
  </xsd:annotation>
  <xsd:sequence>
    <xsd:element name="municipality" type="xsd:string">
      <xsd:annotation>
        <xsd:documentation>
          Some member comment.
        </xsd:documentation>
      </xsd:annotation>
    </xsd:element>
    <xsd:element name="zip" type="xsd:string" />
Run Code Online (Sandbox Code Playgroud)

BaseTaxParametersEnhanced类生成Javadoc 但不为该municipality成员生成Javadoc .

这出乎意料,我没有在文档中提到打开/关闭此标志的标志?

cxf wsdl2java

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

CXF错误:输入消息必须引用具有相同localnameas操作的全局元素声明

在运行wsdl2java时,我收到以下消息:

我使用cxf 3.1和jdk 7我的wsdl2java命令如下

wsdl2java -d C:\esub\.cxftmp/src -classdir C:\esub\build\classes -p http://www.example.org/ESBProxy/=org.example.esbproxy -impl  -exsh false -dns true -dex true -wsdlLocation file:/C:/esub/WebContent/WSDL/ESBProxy.wsdl -verbose -sn ESBProxy -defaultValues -fe jaxws -db jaxb -wv 1.1 file:/C:/esub/WebContent/WSDL/ESBProxy.wsdl
Run Code Online (Sandbox Code Playgroud)

输出:

INFO: Operation {http://www.example.org/ESBProxy/}PublishOnESB cannot be unwrapped, input message must reference global element declaration with same localnameas operation.
Run Code Online (Sandbox Code Playgroud)

下面是我的wsdl

<wsdl:portType name="ESBProxyPortType">
    <wsdl:operation name="PublishOnESB">
        <wsdl:input message="tns:NotifyRequest" />
        <wsdl:output message="tns:NotifyResponse" />
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ESBProxySOAPBinding" type="tns:ESBProxyPortType">
    <soap:binding style="document"
        transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="PublishOnESB" >
        <soap:operation soapAction="http://www.example.org/ESBProxy/PublishOnESB" style="document"/>
        <wsdl:input>
            <soap:body parts="parameters" use="literal" /> …
Run Code Online (Sandbox Code Playgroud)

wsdl web-services cxf wsdl2java jax-ws

7
推荐指数
0
解决办法
1658
查看次数

Axis2命名空间/类路径问题

我在一个Web应用程序上工作,从其代码中调用多个Web服务客户端.

每个Web服务都有一些常见的命名空间,但是当我生成每个客户端时,我正在将这些命名空间映射到不同的包

例如

Web Service 1的namespace1 - > com.company.webservice.client1.service

Web Service 2的namespace1 - > com.company.webservice.client2.service

其中namespace1引用相同的命名空间URL.

使用Wsdl2Java的namespace2package选项:

// Web Service Client 1's namespace parameter
--namespace2package http://www.multispeak.org/Version_3.0=com.company.webservice.client1.service

// Web Service Client 2's namespace parameter
--namespace2package http://www.multispeak.org/Version_3.0=com.company.webservice.client2.service
Run Code Online (Sandbox Code Playgroud)

我可以毫无问题地为这些服务生成Web服务客户端代码,只要生成的客户端jar中只有一个在给定Web服务调用的类路径上,我就可以自己调用每个客户端.但是,如果我将两个Web服务客户端jar放在类路径上,则只有一个Web服务客户端可以工作(其各自的客户端jar首先在类路径上).

尝试调用时,其他Web服务客户端失败,但以下情况除外:

java.lang.ClassCastException:com.company.webservice.client1.service.impl.GetAllMetersResponseDocumentImpl无法强制转换为com.company.webservice.client2.service.GetAllMetersResponseDocument

我已经混淆了上面的一些实际值.

因此,问题似乎是关于Axis2/XMLBeans如何查找适当的类以匹配给定的XML来解析.

我可以更改命名空间映射,以便它们相互匹配,之后它可以正常工作.但是,缺点是我在同一个包结构中有多个包含相同生成代码的Web服务客户端jar,这些类只能从它在类路径中找到的第一个客户端jar中的模型中实例化.

有没有办法这样做,以便我可以为每个Web服务客户端jar保留不同的命名空间?

或者我只是被迫将每个命名空间映射到使用该命名空间的每个客户端的同一个包?

希望这个问题有意义,但是如果我需要提供其他任何有用的东西,请告诉我,我将进一步详细说明这个问题,但希望有使用Wsdl2Java的Axis2/XMLBeans/web服务客户端生成知识的人应该是能够在没有更多信息的情况下回答这个

更新1: 我终于放弃了,只是使所有的命名空间映射指向同一个包而不是每个Web服务客户端的定制,并且在类路径上的各个JAR中获得了同一个类的多个副本.不像我希望的那样优雅,但至少它有效.

如果有人能想出一个更好的解决方案,允许我在每个客户端使用定制副本,请告诉我.

更新2: 这种方法同样不起作用,因为尽管使用相同的命名空间,两个Web服务产生不同版本的命名空间模型,现在导致编译时错误依赖于类路径顺序.那么......回到原点......

java axis2 web-services wsdl2java xmlbeans

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

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
查看次数

为什么WSDL解析器仍然导入外部文档?

我试图以API文档建议的方式关闭导入WSDL4J(1.6.2)中的文档:

  wsdlReader.setFeature("javax.wsdl.importDocuments", false);
Run Code Online (Sandbox Code Playgroud)

实际上,它会停止导入使用wsdl:import标记声明的XML模式文件,但会停止导入使用xs:import标记声明的文件.

以下代码片段[请参阅信函末尾]以获取示例文件

http://www.ibspan.waw.pl/~gawinec/example.wsdl

返回以下异常:

javax.wsdl.WSDLException: WSDLException (at /definitions/types/xs:schema):
faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced
at 'EchoExceptions.xsd', relative to
'http://www.ibspan.waw.pl/~gawinec/example.wsdl'.:
java.io.FileNotFoundException: This file was not found:
http://www.ibspan.waw.pl/~gawinec/EchoExceptions.xsd
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at IsolatedExample.main(IsolatedExample.java:15)
Caused by: java.io.FileNotFoundException: This file was not found:
http://www.ibspan.waw.pl/~gawinec/EchoExceptions.xsd
    at com.ibm.wsdl.util.StringUtils.getContentAsInputStream(Unknown Source)
    ... 10 more …
Run Code Online (Sandbox Code Playgroud)

java parsing wsdl web-services wsdl2java

6
推荐指数
1
解决办法
3112
查看次数

cxf-codegen-plugin 4.0.0 忽略绑定文件

我从基于cxf-codegen-plugin. 我使用额外的绑定

  • 更改包
  • 使用Date而不是XmlGregorianCalender

这适用于版本 3.5.5

当我切换到 4.0.0 时,这不再起作用(默认包并被XmlGregorianCalender使用)。我在迁移指南中找不到任何相关内容。

这是我的配置

pom.xml

<plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>4.0.0</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>https:url?wsdl</wsdl>
                                    <bindingFiles>
                                        <bindingFile>${basedir}/src/main/resources/bindings.xml</bindingFile>
                                    </bindingFiles>
                                    <extraargs>
                                        <extraarg>-verbose</extraarg>
                                        <extraarg>-p</extraarg>
                                        <extraarg>http://url/service=com.some.package</extraarg>
                                        <extraarg>-xjc-Xts:style:org.apache.commons.lang3.builder.ToStringStyle.DEFAULT_STYLE</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.cxf.xjcplugins</groupId>
                        <artifactId>cxf-xjc-ts</artifactId>
                        <version>4.0.0</version>
                    </dependency>
                </dependencies>
            </plugin>
Run Code Online (Sandbox Code Playgroud)

绑定

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<jaxb:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:jaxws="http://cxf.apache.org/jaxws"
               version="2.1">

    <jaxb:bindings schemaLocation="https://url.file.xsd"
                   node="/xsd:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="com.some.package.dto" />
        </jaxb:schemaBindings>
        <jaxb:globalBindings>
            <jaxb:javaType name="java.util.Date"
                           xmlType="xsd:dateTime"
                           parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDateTime"
                           printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDateTime" …
Run Code Online (Sandbox Code Playgroud)

wsdl2java cxf-codegen-plugin

6
推荐指数
2
解决办法
2683
查看次数