2012-03-20 2 views
1

간단한 Webservice를 만들기 위해 annotation driven Spring WS 2.0.4를 사용하고 있지만 enpoint 매핑을 찾을 수 없습니다.아니요 annotation driven을 사용하여 끝점 매핑을 찾았습니다. 동적 WSDL 및 JAXB를 사용하는 Spring WS

입력 및 출력은 JAXB 요소입니다.

카탈 로그에 경고 표시 WebService에 톰캣 7 자바 1.7로 실행

:

경고 : [SaajSoapMessage {에 대한 찾을 수 없습니다 엔드 포인트 매핑을 http://mycompany.com/hr/schemas } HolidayRequest]

코드를 다운로드 할 수 here

스키마 (WEB-INF/HR-데이터 contract.xsd)

,536,913,632 10
<?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

의 localpart가 있어야한다 "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

웹 서비스에 보내는 요청으로 표시 할 수 있습니까? – jddsantaella

+1

확실히, 나는 내 질문의 하단에 보내는 요청을 추가했습니다. –

1

끝점을 aop로 개선해서는 안됩니다. 그렇지 않으면 springws에 비누를 매핑 할 수 없습니다!