0

私は Spring-WS を初めて使用し、自分のプロジェクト用に WebService を作成する必要がありました。いくつかの例を試すために、http: //code.google.com/p/spring-webservices-samples/ から spring-webservices-samples をダウンロードしました。

war ファイルをデプロイして SoapUI を使用してテストすると、応答メッセージに奇妙な文字 ( ce,1a,0など) が含まれており、"CalculateResponse" 要素が空です。

    <ns2:CalculateResponse xmlns:ns2='http://www.marvelution.com/samples/schemas/CalculatorServiceSchema'/> 

そして例外はありません。デバッグしようとしましたが、うまくいきませんでした。

問題を解決してください。ご意見をお待ちしております。

JBoss 4.2.3、Java 1.6 (64 ビット) を使用しています。

Tomcat-7.0.29 で同じ war ファイルを展開しようとしましたが、動作します。しかし、WebService を JBoss 4.2.3 で動作させる必要があります。

TCPMon を使用してキャプチャされたリクエスト:

    POST /annotated-payload-endpoint/calculatorService HTTP/1.1
    Accept-Encoding: gzip,deflate
    Content-Type: text/xml;charset=UTF-8
    SOAPAction: "http://www.marvelution.com/samples/definitions/CalculatorService/Add"
    Content-Length: 377
    Host: 127.0.0.1:9999
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cal="http://www.marvelution.com/samples/schemas/CalculatorServiceSchema">
       <soapenv:Header/>
       <soapenv:Body>
          <cal:Add>
             <!--2 or more repetitions:-->
             <cal:number>1</cal:number>
             <cal:number>2</cal:number>
          </cal:Add>
       </soapenv:Body>
    </soapenv:Envelope>

TCPMon を使用してキャプチャされた応答:

    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)/JBossWeb-2.0
    SOAPAction: ""
    Content-Type: text/xml;charset=UTF-8
    Transfer-Encoding: chunked
    Date: Fri, 20 Jul 2012 01:47:23 GMT

    ce
    <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns2:CalculateResponse xmlns:ns2='http://www.marvelution.com/samples/schemas/CalculatorServiceSchema'/>
    1a
    </env:Body></env:Envelope>
    0

エンドポイント: CalculatorEndpoint.java

    @PayloadRoot(namespace = "http://www.marvelution.com/samples/schemas/CalculatorServiceSchema", localPart = "Add")
    public CalculateResponse add(Add numbers) {
        CalculateResponse res = wrapResult(calculator.add(numbers.getNumber()));
        System.out.println("Response before sending:"+res.getResult());
        return res;
    }

応答を返す直前の System.out.println が出力されています。これらの文字が追加された場所と、応答が不完全な理由がわかりません。

ありがとう、ジェグ

4

1 に答える 1

0

私は問題が何であるかを知りました。JBoss が提供する SAAJ 実装にはいくつかの問題があります。(つまり、このデフォルト JBoss 実装 "org.jboss.ws.core.soap.MessageFactoryImpl" には問題があります) したがって、解決策は JBoss 実装を使用するのではなく、別の実装を使用することです。

例: 次のいずれかの実装を使用します: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessage Factory1_1Impl org.apache.axis2.saaj.MessageFactoryImpl

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
    <property name="messageFactory">
        <bean class="org.apache.axis2.saaj.MessageFactoryImpl"/>
    </property>
</bean>

この問題はすでにここで報告されています: URL: http://static.springsource.org/sprin...tml#saaj-jboss

于 2012-08-11T15:56:35.873 に答える