Web 服务客户端调用部署到 JBoss 的 Web 服务时出现 InstantiationException

发布于 2024-09-14 19:39:24 字数 2166 浏览 1 评论 0原文

我正在将一个带有 @WebService 注释的 StatelessSessionBean 部署到 JBoss。我使用 JBoss 生成的 WSDL 来生成客户端存根。我的问题是调用一个返回对象列表的方法。如果列表为空,则调用成功,但如果列表不为空,则会出现以下异常:

com.sun.xml.ws.encoding.soap.DeserializationException: Failed to read a response: javax.xml.bind.UnmarshalException
 - with linked exception:         
[javax.xml.bind.UnmarshalException: Unable to create an instance of com.companyname.api.ws.DataItemType                                                     
 - with linked exception:
[java.lang.InstantiationException]]
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:124)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
    at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
    at $Proxy34.getWorkflows(Unknown Source)
    at com.companyname.api.SimpleClient.go(SimpleClient.java:48)

搜索网络使我在这里进行了讨论: http://forums.java.net/jive/message.jspa?messageID=281780

但是我已经正确设置了 @XmlSeeAlso 内容并且它存在在生成的存根类上。我可以确认 DataItemType 类是抽象的,因此尝试实例化它会导致问题也就不足为奇了。我根本不清楚为什么要实例化 DataItemType 类(因为它是抽象的)。这是从服务器返回的 XML(对我来说看起来很正确):

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
    <env:Header></env:Header>
    <env:Body>
        <ns2:getWorkflowsResponse xmlns:ns2="http://ws.api.companyname.com/">
            <return>
                <id>
                    <identifier>1</identifier>
                    <version>0</version>
                </id>
                <goal>ENROLL</goal>
                <dataItemType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="DataItemTypeText">
                    <attributeName>email</attributeName>
                    <displayName>Email Address</displayName>
                </dataItemType>
                ...
            </return>
        </ns2:getWorkflowsResponse>
    </env:Body>
</env:Envelope>

有谁知道我做错了什么?

I'm deploying a StatelessSessionBean annotated with @WebService to JBoss. I'm taking the WSDL generated by JBoss to generate client stubs. My problem is in calling a method which returns a list of objects. If the list is empty the call succeeds however if the list is not empty then I get the following exception:

com.sun.xml.ws.encoding.soap.DeserializationException: Failed to read a response: javax.xml.bind.UnmarshalException
 - with linked exception:         
[javax.xml.bind.UnmarshalException: Unable to create an instance of com.companyname.api.ws.DataItemType                                                     
 - with linked exception:
[java.lang.InstantiationException]]
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:124)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
    at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
    at $Proxy34.getWorkflows(Unknown Source)
    at com.companyname.api.SimpleClient.go(SimpleClient.java:48)

Searching the web led me to this discussion here: http://forums.java.net/jive/message.jspa?messageID=281780

However I have set the @XmlSeeAlso stuff correctly and it is present on the generated stub classes. I can confirm that the DataItemType class is abstract so it is not surprising that an attempt to instantiate it causes a problem. I'm not at all clear on why the DataItemType class is being instantiated at all (as it is abstract). This is the XML that is returned from the server (it looks about right to me):

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
    <env:Header></env:Header>
    <env:Body>
        <ns2:getWorkflowsResponse xmlns:ns2="http://ws.api.companyname.com/">
            <return>
                <id>
                    <identifier>1</identifier>
                    <version>0</version>
                </id>
                <goal>ENROLL</goal>
                <dataItemType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="DataItemTypeText">
                    <attributeName>email</attributeName>
                    <displayName>Email Address</displayName>
                </dataItemType>
                ...
            </return>
        </ns2:getWorkflowsResponse>
    </env:Body>
</env:Envelope>

Does anyone know what I'm doing wrong?

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

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

发布评论

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

评论(1

她说她爱他 2024-09-21 19:39:24

生成的 WSDL 存在许多问题(请注意,它不是手工制作的)。我没有更改任何具体内容来表明为什么抛出此特定异常(或者例如为什么在生成不正确的 WSDL 时没有失败)。

一旦我调整了注释以便创建了有效的 WSDL,那么我使用的 JAX-WS 版本就遇到了进一步的问题。我最终升级了 JBoss 使用的版本,这又导致我需要将较新的 JAX-WS jar 放入我的 JRE 认可的目录中。

我不会更详细地描述我所做的事情,因为我没有做任何具体的事情来解决这个问题。如果其他人看到它,我建议您在用于生成 WSDL 的注释中非常具体,并仔细查看您的 WSDL。

There were a number of issues with the generated WSDL (note that it wasn't a handcrafted one). There was nothing specific that I changed which indicated why this particular exception was thrown (or why, for example, there wasn't a failure when generating the incorrect WSDL).

Once I adjusted the annotations so that a valid WSDL was created then I had further issues which the JAX-WS versions I was using. I ended up upgrading the version used by JBoss which, in turn, led to me needing put the newer JAX-WS jars in my JRE endorsed directory.

I'm not going to detail what I did in any more detail as there was no specific thing that I did that addressed this problem. If anyone else sees it I would suggest being very specific in the annotations you use to generate your WSDL and taking a careful look at your WSDL.

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