2011-04-11 4 views
5

SLSB 및 JAX-WS 주석을 사용하여 간단한 SOAP 웹 서비스를 만들고 있습니다. 내가 전달하고자하는 객체는 OGC 스키마에서 생성 된 JAXB, java.net의 OGC 프로젝트에 대한 감사입니다. 문제가있는 특정 방법 (예 : )은 요청 개체 (GetResult)의 필드 (eventTime) 이 요청 개체와 다른 패키지에있는 상황입니다. 이 형식의 ObjectFactory는 달라서 마샬링/언 마샬링 할 때 이 문제가됩니다.SLSB 및 JAX-WS에서 JAXB 패키지 지정

내가지고있어 오류의 부분 집합 : 나는 아래 같은 JAXBContext에를 초기화 할 때 표준 SE 응용 프로그램에서

There's no ObjectFactory with an @XmlElementDecl for the element {http://www.opengis.net/ogc}temporalOps. this problem is related to the following location: at protected javax.xml.bind.JAXBElement net.opengis.sos.v_1_0_0.GetResult$EventTime.temporalOps at net.opengis.sos.v_1_0_0.GetResult$EventTime at protected java.util.List net.opengis.sos.v_1_0_0.GetResult.eventTime at net.opengis.sos.v_1_0_0.GetResult at public net.opengis.sos.v_1_0_0.GetResult net.opengis.sos.v_1_0_0.ObjectFactory.createGetResult() at net.opengis.sos.v_1_0_0.ObjectFactory

는, 모든 것이 잘 작동합니다.

JAXBContext context = JAXBContext.newInstance("net.opengis.sos.v_1_0_0:net.opengis.sensorml.v_1_0_1:net.opengis.sos.v_1_0_0.filter.v_1_1_0"); 

어떻게 JAX-WS 컨텍스트에서 JAXB 패키지를 설정합니까?

내 앱 서버/환경은 GF 3.1입니다.

도움 주셔서 감사합니다.

스티브

+0

[이 블로그] (http://weblogs.java.net/blog/kohlert/archive/2006/10/jaxws_and_type.html)는 서비스 클래스에서 @XmlSeeAlso의 사용이 실제로 유망 해 보이지만 그 것처럼 보입니다. JAX-WS 2.2까지 채택되지 않았습니다. 메트로 (JAX-RS RI 프로젝트를 통해) 2.2 사양을 지원하는 것 같습니다 ...하지만 아직 꽤 작동하지 않습니다. 그것을 GF 3.0.1에서 시도해보십시오 ... 아마도 JAX-WS의 호환 버전을 가지고 있지 않습니다. 오늘 밤 나중에 시도하십시오. 생각, 누구? –

+0

@XmlSeeAlso는 좋은 접근 방법 인 것처럼 보였지만 문제를 해결하지 못했습니다. 나는 @UsesJAXBContext를 지적했지만 지하철에는 [버그] (http://java.net/jira/browse/JAX_WS-270)가 있는데 JAXBContextFactory I의 createJAXBContext()를 호출하지 않는 것으로 보인다. 창조 된, 몇 년 동안 열려있다. 조사는 계속됩니다 .... –

답변

3

가 나는 @UsesJAXBContext 작업 있어요 -. NB 6.9 및 7.0b가 com.sun.internal을 연결하고 싶었 기 때문에 처음에는 약간의 문제가 있었다 * UsesJAXBContext과 관련, 버전하는 과정 JAX-WS RI가 찾고있는 것이 아닙니다. 일단이 문제를 고치고 jaxws-rt 2.2.3 버전에 종속성을 추가하면 모든 것이 잘 작동합니다. OGC의 포인터에 (java.net 프로젝트) 메일 링리스트 알렉세이 Valikov에

@WebService(serviceName = "SOS")//, targetNamespace = "http://www.opengis.net/sos/1.0") 
@UsesJAXBContext(value = SosServices.SosJaxbContext.class) 
//@XmlSeeAlso({net.opengis.sos.v_1_0_0.filter.v_1_1_0.ObjectFactory.class, net.opengis.sensorml.v_1_0_1.ObjectFactory.class}) 
public class SosServices { 

@WebMethod(operationName = "GetResult") 
    public GetResultResponse getResult(GetResult request) { 
     throw new UnsupportedOperationException(); 
    } 

public static class SosJaxbContext implements JAXBContextFactory { 

     @Override 
     public JAXBRIContext createJAXBContext(SEIModel sei, 
       List<Class> classesToBind, List<TypeReference> typeReferences) 
       throws JAXBException { 

      List<Class> classList = new ArrayList<Class>(); 
      classList.addAll(classesToBind); 
      classList.add(TemporalOpsType.class); 

      List<TypeReference> refList = new ArrayList<TypeReference>(); 
      refList.addAll(typeReferences); 
      refList.add(new TypeReference(new QName("http://www.opengis.net/ogc", "temporalOps"), TemporalOpsType.class)); 

      return JAXBRIContext.newInstance(classList.toArray(new Class[classList.size()]), 
        refList, null, sei.getTargetNamespace(), false, null); 
     } 
    } 
} 

덕분에 @UsesJAXBContext합니다!