首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >[JAVA Spring SOAP WSDL]

[JAVA Spring SOAP WSDL]
EN

Stack Overflow用户
提问于 2015-03-30 22:49:54
回答 2查看 4.6K关注 0票数 0

我尝试使用spring/soap/wsdl连接到Web服务。我收到的堆栈跟踪信息如下:

代码语言:javascript
运行
复制
Exception in thread "main" org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Unable to create envelope from given source: ; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source: 
    at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:216)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:60)
    at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:92)
    at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:608)
    at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383)
    at com.arek.soapallegrotest.WsSearchClient.doLogin(WsSearchClient.java:60)
    at com.arek.soapallegrotest.WsSearchClient.doSearchResponse(WsSearchClient.java:81)
    at com.arek.soapallegrotest.SpringMain.main(SpringMain.java:24)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source: 
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:117)
    at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:69)
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:128)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:189)
    ... 9 more
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source because the root element is not named "Envelope"
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.lookForEnvelope(SOAPPartImpl.java:154)
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:121)
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(Envel

opeFactory.java:110)
    ... 12 more
2015-03-30 16:30:26.747  INFO 12079 --- [       Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@3cb1ffe6: startup date [Mon Mar 30 16:30:24 CEST 2015]; root of context hierarchy

我已经使用了这个教程:https://spring.io/guides/gs/consuming-web-service/#initial来学习我自己。

我发现了一些关于命名空间有问题的信息?

ps。对不起,我的英语

EN

回答 2

Stack Overflow用户

发布于 2016-02-27 03:18:47

我也有同样的问题,原因如下:

代码语言:javascript
运行
复制
WebServiceTemplate template = new WebServiceTemplate(messageFactory());
...    
template.setDefaultUri("http://host:2121/portal/service?wsdl");

解决方案是删除?wsdl

票数 2
EN

Stack Overflow用户

发布于 2015-04-29 20:56:24

我也有同样的问题。我不知道到底是什么原因导致了你的源代码,因为你没有添加任何具体的信息,但我可以告诉我的项目中,当我添加fop到我的pom时,它开始给出这个错误:

代码语言:javascript
运行
复制
    <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>fop</artifactId>
        <version>1.1</version>
        <!-- some exclusions needed because of inexistent "avalon" packages in maven repositories -->
    </dependency>

我通过maven找到的fop的每一个版本都会发生这种情况。

我找到了一个solution here。显然,fop中包含的xalan和xerces需要升级。

我对这个解决方案不满意,但它是有效的。我留下了一些排除,我不确定是否需要,或者可能会破坏其他东西,因为最后期限来得非常快(哈哈哈)。我将在稍后讨论这个问题(或者希望其他人能对此发表评论)。

下面我添加我的pom片段:

代码语言:javascript
运行
复制
    <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>fop</artifactId>
        <version>1.1</version>
        <exclusions>
            <!-- 
                Following avalon-framework versions that come 
                as dependencies for fop 1.1 are not found 
                through maven:

                See: https://issues.apache.org/jira/browse/FOP-2151 
             -->
            <exclusion>
                <groupId>org.apache.avalon.framework</groupId>
                <artifactId>avalon-framework-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.avalon.framework</groupId>
                <artifactId>avalon-framework-impl</artifactId>
            </exclusion>
            <!-- 
                Without following exclusions I get the following 
                exception when trying to access another web service:
                2015-04-24 13:48:25,048 ERROR [http-nio-8084-exec-2] (CfdiController.java:152) - 
                Error while uploading. org.springframework.ws.soap.SoapMessageCreationException: 
                Could not create message from InputStream: Unable to create envelope from given 
                source: ; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: 
                Unable to create envelope from given source: 
                at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:216) 
                ~[spring-ws-core-2.2.0.RELEASE.jar:2.2.0.RELEASE]

                See: https://stackoverflow.com/a/13156775/2796922
            -->
            <exclusion>
                <artifactId>maven-cobertura-plugin</artifactId>
                <groupId>maven-plugins</groupId>
            </exclusion>
            <exclusion>
                <artifactId>maven-findbugs-plugin</artifactId>
                <groupId>maven-plugins</groupId>
            </exclusion>
            <exclusion>
                <artifactId>xalan</artifactId>
                <groupId>xalan</groupId>
            </exclusion>
            <exclusion>
                <artifactId>xercesImpl</artifactId>
                <groupId>xerces</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- 
        These avalon dependencies are found in maven:
    -->
    <dependency>
        <groupId>avalon-framework</groupId>
        <artifactId>avalon-framework-api</artifactId>
        <version>4.2.0</version>
    </dependency>
    <dependency>
        <groupId>avalon-framework</groupId>
        <artifactId>avalon-framework-impl</artifactId>
        <version>4.2.0</version>
    </dependency>

    <!--  
        With these versions is no longer raised the  
        "Unable to create envelope from given source"
        exception explained before
    -->
    <dependency>
        <groupId>xalan</groupId>
        <artifactId>xalan</artifactId>
        <version>2.7.0</version>
        <type>jar</type>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>xml-apis</artifactId>
                <groupId>xml-apis</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.9.1</version>
        <type>jar</type>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>xml-apis</artifactId>
                <groupId>xml-apis</groupId>
            </exclusion>
        </exclusions>
    </dependency>

希望能有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29349361

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档