4

単純なPOJOベースのサービスをサービスアクティベーターを介してSOAPベースのWebサービスに公開することに特に関心のあるSpringIntegrationを評価しようとしています。現在、スタックしていて、動的wsdlの生成に問題があります。WSDLがロードされておらず、ブラウザに404エラーが表示されます。ローカルで次のURLを使用してアクセスしようとしています

http://localhost:8080/ws-inbound-gateway/echoService
http://localhost:8080/ws-inbound-gateway/echoService/echoService.wsdl

以下は構成です

inbound-gateway-config.xml

<int:channel id="inbound" />

    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="contextPath" value="com.manish.schema.generated" />
    </bean>

    <int-ws:inbound-gateway id="empServiceGateway"
        request-channel="inbound" marshaller="marshaller"
        unmarshaller="marshaller" />

    <int:service-activator input-channel="inbound"
        requires-reply="true" ref="employeeServiceActivator" method="getEmployeeDetails">

    </int:service-activator>

    <bean id="employeeServiceActivator"
        class="org.springframework.integration.samples.ws.EmployeeServiceResponder" />

    <bean id="employeeService" class="com.manish.service.EmployeeService" />

EmployeeServiceは単なるpojoクラスですが、EmployeeServiceResponderはサービスクラスのメソッドを呼び出すサービスアクティベーターです。

動的wsdl生成の場合

spring-ws-config.xml

<import resource="classpath:/META-INF/spring/integration/inbound-gateway-config.xml" />

<sws:dynamic-wsdl id="echoService" portTypeName="empServiceGateway" locationUri="/echoService" targetNamespace="http://manish.niyati.com/echo">
    <sws:xsd location="/WEB-INF/echo.xsd"/>
</sws:dynamic-wsdl>

<bean
    class="org.springframework.ws.server.endpoint.mapping.UriEndpointMapping">
    <property name="defaultEndpoint" ref="empServiceGateway"></property>
</bean>

web.xml

<servlet>
    <servlet-name>spring-ws</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/spring-ws-config.xml</param-value>
    </init-param>
    <init-param>
        <param-name>transformWsdlLocations</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>spring-ws</servlet-name>
    <url-pattern>/echoService</url-pattern>
</servlet-mapping>

このサービスをSI経由でWebサービスとしてアクセスできるようにするために、他に不足しているものを教えてください。

また、WebServiceテンプレートを使用してサービスにアクセスしようとすると、SOAPFAULTが表示されます。

02:18:59.436 INFO  [main][org.springframework.ws.soap.saaj.SaajSoapMessageFactory] Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
02:18:59.437 DEBUG [main][org.springframework.ws.soap.saaj.SaajSoapMessageFactory] Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
02:18:59.484 DEBUG [main][org.springframework.ws.client.core.WebServiceTemplate] Opening [org.springframework.ws.transport.http.HttpUrlConnection@249fa95c] to [http://localhost:8080/ws-inbound-gateway/echoService]
02:18:59.519 TRACE [main][org.springframework.ws.soap.saaj.support.SaajUtils] SOAPElement [com.sun.xml.internal.messaging.saaj.soap.ver1_1.Envelope1_1Impl] implements SAAJ 1.3
02:18:59.535 TRACE [main][org.springframework.ws.soap.saaj.support.SaajUtils] SOAPElement [com.sun.xml.internal.messaging.saaj.soap.ver1_1.Body1_1Impl] implements SAAJ 1.3
02:18:59.562 TRACE [main][org.springframework.ws.client.MessageTracing.sent] Sent request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ed:employeeRequest xmlns:ed="http://manish.niyati.com/echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ed:empid>100</ed:empid> </ed:employeeRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>]
02:18:59.604 TRACE [main][org.springframework.ws.client.MessageTracing.received] Received response [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring xml:lang="en">**java.lang.NullPointerException**</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>] for request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ed:employeeRequest xmlns:ed="http://manish.niyati.com/echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ed:empid>100</ed:empid> </ed:employeeRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>]
02:18:59.605 DEBUG [main][org.springframework.ws.client.core.WebServiceTemplate] Received Fault message for request [SaajSoapMessage {http://manish.niyati.com/echo}employeeRequest]
02:18:59.607 TRACE [main][org.springframework.ws.soap.saaj.support.SaajUtils] SOAPElement [com.sun.xml.internal.messaging.saaj.soap.ver1_1.Fault1_1Impl] implements SAAJ 1.3

事前に感謝-MS

4

2 に答える 2

0

はるかに複雑な方法でそれを行っています。簡単な構成といくつかの基本的なアノテーションを使用して、短時間で Web サービスを開発できます。

私自身、Web サービスの開発にApache CXFを使用しましたが、Spring ベースの構成には非常に適しています。こちらのブログもご覧ください。wsdl の生成と Web サービスを使用するクライアントを使用して Web サービスを開発するためのすべての手順を図で示しました。

于 2013-03-22T08:57:08.650 に答える
0

WSDL を取得するには、web.xml url-pattern を に変更し<url-pattern>/*</url-pattern>ます。

URL はhttp://localhost:8080/ws-inbound-gateway/echoService.wsdlです。

他のすべてはよさそうだ。

WebServiceTemplateQuestion について、何を送信していますか? WebServiceTemplate を使用する ws サンプル アプリを使用しているようです...

@Test
public void testWebServiceRequestAndResponse() {
    StringResult result = new StringResult();
    Source payload = new StringSource(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<echoRequest xmlns=\"http://www.springframework.org/spring-ws/samples/echo\">hello</echoRequest>");

    template.sendSourceAndReceiveToResult(WS_URI, payload, result);
    logger.info("RESULT: " + result.toString());
    assertThat(result.toString(), equalTo(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<echoResponse xmlns=\"http://www.springframework.org/spring-ws/samples/echo\">hello</echoResponse>"));
}

そして、それはうまく機能します。

NPE がサーバー上にあるようです。サーバー ログを見て、何が起こったかを確認してください。

于 2013-03-22T13:08:25.147 に答える