从 wsgen 工具生成 wsdl 时出错

发布于 2024-11-03 23:11:32 字数 5228 浏览 1 评论 0原文

我正在 wsgen 工具的帮助下尝试生成 wsdl。我已经认可了 jaxb-api.jar 和 jaxws-api.jar 文件。

我有一个 TestTo 库,其中包含 TestTo 类 AS

public class TestingTo implements Serializable{
    public String name;
}

该 TestTO 库包含在 webservice 项目中。

我的 WebService 如下 -

@WebService()
public class IcfInfra {

    @WebMethod(operationName = "printTest")
    public TestingTo printTest(@WebParam(name = "string") String string)
    {
        TestingTo to = new TestingTo();
        to.name = string;
        System.out.println(string);
        return to;
    }
}

当我为 Wsgen 运行 Ant 脚本时,出现以下错误 -

main:
     [exec] Note:       ap round: 1
     [exec] Problem encountered during annotation processing;
     [exec] see stacktrace below for more information.
     [exec] java.lang.NullPointerException
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.isLegalType(WebServiceVisitor.java:794)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.isLegalMethod(WebServiceVisitor.java:642)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.methodsAreLegal(WebServiceVisitor.java:611)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.isLegalImplementation(WebServiceVisitor.java:529)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.shouldProcessWebService(WebServiceVisitor.java:332)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.visitClassDeclaration(WebServiceVisitor.java:123)
     [exec]     at com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.acc
ept(ClassDeclarationImpl.java:95)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.bu
ildModel(WebServiceAP.java:329)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.pr
ocess(WebServiceAP.java:270)
     [exec]     at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationPr
ocessor.process(AnnotationProcessors.java:60)
     [exec]     at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
     [exec]     at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java
:258)
     [exec]     at com.sun.tools.apt.main.Main.compile(Main.java:1102)
     [exec]     at com.sun.tools.apt.main.Main.compile(Main.java:964)
     [exec]     at com.sun.tools.apt.Main.processing(Main.java:95)
     [exec]     at com.sun.tools.apt.Main.process(Main.java:85)
     [exec]     at com.sun.tools.apt.Main.process(Main.java:67)
     [exec]     at com.sun.tools.ws.wscompile.WsgenTool.buildModel(WsgenTool.jav
a:219)
     [exec]     at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:123)
     [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
     [exec]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
     [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
     [exec]     at com.sun.tools.ws.Invoker.invoke(Invoker.java:131)
     [exec]     at com.sun.tools.ws.WsGen.main(WsGen.java:52)
     [exec] error: compilation failed, errors should have been reported
     [exec] Result: 1

现在我将我的 Web 服务修改为

@WebService()
@XmlSeeAlso({
    TestingTo.class
})
public class IcfInfra {
   ...
}

当我执行 ant 脚本时,出现错误 -

main:
     [exec] Exception in thread "main" java.lang.ArrayStoreException: sun.reflec
t.annotation.TypeNotPresentExceptionProxy
     [exec]     at sun.reflect.annotation.AnnotationParser.parseClassArray(Annot
ationParser.java:653)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseArray(Annotation
Parser.java:460)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseMemberValue(Anno
tationParser.java:286)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseAnnotation(Annot
ationParser.java:222)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Ann
otationParser.java:69)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseAnnotations(Anno
tationParser.java:52)
     [exec]     at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
     [exec]     at java.lang.Class.getAnnotation(Class.java:3029)
     [exec]     at com.sun.tools.ws.wscompile.WsgenOptions.validateEndpointClass
(WsgenOptions.java:244)
     [exec]     at com.sun.tools.ws.wscompile.WsgenOptions.validate(WsgenOptions
.java:226)
     [exec]     at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:122)
     [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
     [exec]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
     [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
     [exec]     at com.sun.tools.ws.Invoker.invoke(Invoker.java:131)
     [exec]     at com.sun.tools.ws.WsGen.main(WsGen.java:52)

感谢如果有人能让我知道需要做什么才能成功生成 wsdl。

谢谢, 阿迪什

I am trying out wsdl generation with the help of the wsgen tool. I have endorsed jaxb-api.jar and jaxws-api.jar files.

I have a library TestTo which has TestingTo class AS

public class TestingTo implements Serializable{
    public String name;
}

This TestTO library is included in webservice project.

My WebService is as below-

@WebService()
public class IcfInfra {

    @WebMethod(operationName = "printTest")
    public TestingTo printTest(@WebParam(name = "string") String string)
    {
        TestingTo to = new TestingTo();
        to.name = string;
        System.out.println(string);
        return to;
    }
}

When I run Ant script for Wsgen I get following error -

main:
     [exec] Note:       ap round: 1
     [exec] Problem encountered during annotation processing;
     [exec] see stacktrace below for more information.
     [exec] java.lang.NullPointerException
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.isLegalType(WebServiceVisitor.java:794)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.isLegalMethod(WebServiceVisitor.java:642)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.methodsAreLegal(WebServiceVisitor.java:611)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.isLegalImplementation(WebServiceVisitor.java:529)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.shouldProcessWebService(WebServiceVisitor.java:332)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisit
or.visitClassDeclaration(WebServiceVisitor.java:123)
     [exec]     at com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.acc
ept(ClassDeclarationImpl.java:95)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.bu
ildModel(WebServiceAP.java:329)
     [exec]     at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.pr
ocess(WebServiceAP.java:270)
     [exec]     at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationPr
ocessor.process(AnnotationProcessors.java:60)
     [exec]     at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
     [exec]     at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java
:258)
     [exec]     at com.sun.tools.apt.main.Main.compile(Main.java:1102)
     [exec]     at com.sun.tools.apt.main.Main.compile(Main.java:964)
     [exec]     at com.sun.tools.apt.Main.processing(Main.java:95)
     [exec]     at com.sun.tools.apt.Main.process(Main.java:85)
     [exec]     at com.sun.tools.apt.Main.process(Main.java:67)
     [exec]     at com.sun.tools.ws.wscompile.WsgenTool.buildModel(WsgenTool.jav
a:219)
     [exec]     at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:123)
     [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
     [exec]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
     [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
     [exec]     at com.sun.tools.ws.Invoker.invoke(Invoker.java:131)
     [exec]     at com.sun.tools.ws.WsGen.main(WsGen.java:52)
     [exec] error: compilation failed, errors should have been reported
     [exec] Result: 1

Now I modified my webservice as

@WebService()
@XmlSeeAlso({
    TestingTo.class
})
public class IcfInfra {
   ...
}

When I execute ant script i get error as -

main:
     [exec] Exception in thread "main" java.lang.ArrayStoreException: sun.reflec
t.annotation.TypeNotPresentExceptionProxy
     [exec]     at sun.reflect.annotation.AnnotationParser.parseClassArray(Annot
ationParser.java:653)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseArray(Annotation
Parser.java:460)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseMemberValue(Anno
tationParser.java:286)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseAnnotation(Annot
ationParser.java:222)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Ann
otationParser.java:69)
     [exec]     at sun.reflect.annotation.AnnotationParser.parseAnnotations(Anno
tationParser.java:52)
     [exec]     at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
     [exec]     at java.lang.Class.getAnnotation(Class.java:3029)
     [exec]     at com.sun.tools.ws.wscompile.WsgenOptions.validateEndpointClass
(WsgenOptions.java:244)
     [exec]     at com.sun.tools.ws.wscompile.WsgenOptions.validate(WsgenOptions
.java:226)
     [exec]     at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:122)
     [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
     [exec]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
     [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
     [exec]     at com.sun.tools.ws.Invoker.invoke(Invoker.java:131)
     [exec]     at com.sun.tools.ws.WsGen.main(WsGen.java:52)

Appreciate If someone can let me know what needs to be done in order to sucessfully generate the wsdl.

Thanks,
Adish

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我通常使用CXF作为SOAP实现并使用maven进行项目配置,请参阅最后的链接(有一个示例项目可供下载)。但我的猜测是,您必须像这样设置 TestTo 类的访问器类型(请参阅 javadoc):

@XmlAccessorType( XmlAccessType.FIELD )
public class TestingTo implements Serializable{
    public String name;
}

CXF:使用 java 生成的 wsdl 定义契约优先 Web 服务

I usualy use CXF as SOAP implementation and maven for project configuration, see the link at the end (there is a sample project to download). But my guess is that you have to set the accessor type for your TestingTo class like this (see javadoc):

@XmlAccessorType( XmlAccessType.FIELD )
public class TestingTo implements Serializable{
    public String name;
}

CXF: Defining Contract first webservices with wsdl generation from java

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文