2012-03-20 2 views
1

私はアノテーション駆動のSpring WS 2.0.4を使用して簡単なWebサービスを作成していますが、enpointマッピングは見つかりませんでした。アノテーションを使用してエンドポイントマッピングが見つかりましたSpring WSと動的wsdlおよびJAXB

入力と出力はJAXB要素です。

Catalinaのログに警告示すWebServiceがTomcatの7上のJava 1.7で実行されて

WARNING:[SaajSoapMessage {見つかりませんエンドポイントマッピングをhttp://mycompany.com/hr/schemas } HolidayRequest]

コードは、ダウンロードのために利用可能であるhere

スキーマ(WEB-INF/HR-データcontract.xsd):

<?xml version="1.0" encoding="UTF-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     targetNamespace="http://mycompany.com/hr/schemas" 
     xmlns:hr="http://mycompany.com/hr/schemas" 
     elementFormDefault="qualified"> 

     <xs:element name="HolidayRequest"> 
      <xs:complexType> 
       <xs:sequence> 
        <xs:element name="empId" type="xs:integer" /> 
        <xs:element name="days" type="xs:integer" /> 
       </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     <xs:element name="HolidayResponse"> 
      <xs:complexType> 
       <xs:sequence> 
        <xs:element name="empId" type="xs:integer" /> 
        <xs:element name="isApproved" type="xs:boolean" /> 
       </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
</xs:schema> 

スプリング設定(/WEB-INF/spring-ws-servlet.xml)

<sws:annotation-driven/> 

    <context:component-scan base-package="com.mycompany.hr.model" /> 

    <sws:dynamic-wsdl 
     id="holiday" 
     portTypeName="HumanResource" 
     locationUri="/holidayService/" 
     targetNamespace="http://mycompany.com/hr/definitions"> 
     <sws:xsd location="/WEB-INF/hr-data-contract.xsd" /> 
    </sws:dynamic-wsdl> 

エンドポイント(SRC /メイン/ COM/mycompanyの/時間/サービス/ HolidayEndpoint.java)

@Endpoint 
public class HolidayEndpoint { 

    private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas"; 

    private HolidayService holidaySvc; 

    @Autowired 
    public HolidayEndpoint(HolidayService holidaySvc) { 
     this.holidaySvc = holidaySvc; 
    } 

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest") 
    @ResponsePayload 
    public JAXBElement<HolidayResponse> handleHolidayRequest(@RequestPayload HolidayRequest request) { 

     HolidayResponse response = new HolidayResponse(); 

     response.setIsApproved(holidaySvc.requestHoliday(request.getEmpId(), request.getDays())); 
     response.setEmpId(request.getEmpId()); 

     return new JAXBElement<HolidayResponse>(
       new QName(
        NAMESPACE_URI, 
       "HolidayResponse"), 
       HolidayResponse.class, 
       response); 
    } 
} 

そして、これは、自動生成されたWSDLである:ここでは

<wsdl:definitions targetNamespace="http://mycompany.com/hr/definitions" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://mycompany.com/hr/schemas" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://mycompany.com/hr/definitions"> 
    <wsdl:types> 
     <xs:schema elementFormDefault="qualified" targetNamespace="http://mycompany.com/hr/schemas" xmlns:hr="http://mycompany.com/hr/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
     <xs:element name="HolidayRequest"> 
      <xs:complexType> 
       <xs:sequence> 
        <xs:element name="empId" type="xs:integer"/> 
        <xs:element name="days" type="xs:integer"/> 
       </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     <xs:element name="HolidayResponse"> 
      <xs:complexType> 
       <xs:sequence> 
        <xs:element name="empId" type="xs:integer"/> 
        <xs:element name="isApproved" type="xs:boolean"/> 
       </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     </xs:schema> 
    </wsdl:types> 
    <wsdl:message name="HolidayResponse"> 
     <wsdl:part element="sch:HolidayResponse" name="HolidayResponse"/> 
    </wsdl:message> 
    <wsdl:message name="HolidayRequest"> 
     <wsdl:part element="sch:HolidayRequest" name="HolidayRequest"/> 
    </wsdl:message> 
    <wsdl:portType name="HumanResource"> 
     <wsdl:operation name="Holiday"> 
     <wsdl:input message="tns:HolidayRequest" name="HolidayRequest"/> 
     <wsdl:output message="tns:HolidayResponse" name="HolidayResponse"/> 
     </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="HumanResourceSoap11" type="tns:HumanResource"> 
     <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
     <wsdl:operation name="Holiday"> 
     <soap:operation soapAction=""/> 
     <wsdl:input name="HolidayRequest"> 
      <soap:body use="literal"/> 
     </wsdl:input> 
     <wsdl:output name="HolidayResponse"> 
      <soap:body use="literal"/> 
     </wsdl:output> 
     </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="HumanResourceService"> 
     <wsdl:port binding="tns:HumanResourceSoap11" name="HumanResourceSoap11"> 
     <soap:address location="http://localhost:8080/holidayService/holidayService/"/> 
     </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

私はSを使用してhttp://localhost:8080/holidayService/holidayService/に送信していたサンプル要求でありますoapUI

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://mycompany.com/hr/schemas"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <sch:HolidayRequest> 
     <sch:empId>1</sch:empId> 
     <sch:days>3</sch:days> 
     </sch:HolidayRequest> 
    </soapenv:Body> 
</soapenv:Envelope> 

答えて

4

ローカル部があるべき "HolidayRequest"

編集:これを試してみてください。

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest") 
public HolidayResponse handleHolidayRequest(HolidayRequest request) { 

    HolidayResponse response = new HolidayResponse(); // JAXB object 

    response.setIsApproved(holidaySvc.requestHoliday(request.getEmpId(), request.getDays())); 
    response.setEmpId(request.getEmpId()); 

    return response; 
} 

編集 2(!!エンドポイントクラスを含める必要があり、あなたの基本パッケージ):

設定は次のようになります。

<sws:annotation-driven/> 

<context:component-scan base-package="com.mycompany" /> 

<!-- enable autowire --> 
<context:annotation-config /> 

<sws:dynamic-wsdl 
    id="holiday" 
    portTypeName="HumanResource" 
    locationUri="/holidayService/" 
    targetNamespace="http://mycompany.com/hr/definitions"> 
    <sws:xsd location="/WEB-INF/hr-data-contract.xsd" /> 
</sws:dynamic-wsdl> 
+0

私はHolidayRequestに変更しました。カタリナのログにも同じ警告が表示されます –

+0

Webサービスに送信するリクエストとして表示できますか? – jddsantaella

+1

確かに、私は私の質問の下に送信している要求を追加しました –

1

エンドポイントをaopで拡張しないでください。さもなければ、springwsはそれに石鹸を割り当てることができません!

関連する問題