【问题标题】:[JAVA Spring SOAP WSDL][JAVA Spring SOAP WSDL]
【发布时间】:2015-03-30 14:49:53
【问题描述】:

我尝试使用 spring/soap/wsdl 连接到 Web 服务。我收到这样的堆栈跟踪:

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。对不起我的英语

【问题讨论】:

  • 您找到解决方案了吗?
  • 我还没有找到我的问题的解决方案。我已经将没有 spring 的 jaxws 用于网络服务,它工作正常。

标签: java spring soap wsdl


【解决方案1】:

我遇到了同样的问题,原因是这样的:

WebServiceTemplate template = new WebServiceTemplate(messageFactory());
...    
template.setDefaultUri("http://host:2121/portal/service?wsdl");

解决方案是删除?wsdl

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。我不知道究竟是什么在您的来源中导致了这种情况,因为您没有添加任何特定信息,但我可以告诉它,当我将 fop 添加到我的 pom 时,它开始在我的项目中出现此错误:

        <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 片段:

        <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>
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-24
      • 1970-01-01
      • 2018-09-23
      • 1970-01-01
      • 2012-05-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多