2017-12-11 3 views
0

안녕하세요, Camel-SOAP 구성 요소를 사용하여 MQ를 사용하여 보낸 비누 메시지를 비 정렬 화하려고합니다. 하지만 내가, XSD 년대를 provieded WSDL을 사용하여 생성 된 내 JAXB 콩을 받는다는-JAXB2-플러그인을 사용하고 있습니다에 필요한 ServiceInterfaceStrategy 및 SoapJaxbDataFormatCamel-SOAP unmarshal 사용 방법

을 사용하는 방법을 알아낼 수 없습니다.

어떤 클래스를 사용해야합니까?
maven-jaxb2-plugin으로 어떻게 생성 할 수 있습니까?

SoapJaxbDataFormat soap = new 
SoapJaxbDataFormat("xx.xxx.service._201x._01._01.notification", new 
ServiceInterfaceStrategy(WHAT_CLASS_TO_USE.class, false)); 

답변

1

그리고 받는다는-JAXB2 - 플러그인을 어떻게 생성합니까?

<plugin> 
    <groupId>org.jvnet.jaxb2.maven2</groupId> 
    <artifactId>maven-jaxb2-plugin</artifactId> 
    <version>0.13.1</version> 
    <executions> 
     <execution> 
      <id>generate</id> 
      <goals> 
       <goal>generate</goal> 
      </goals> 
      <configuration> 
       <schemaDirectory>src/test/resources/wsdl</schemaDirectory> 
       <generatePackage>org.tempuri.calculator.jaxb2</generatePackage> 
       <generateDirectory>src/test/java</generateDirectory> 
       <clearOutputDir>false</clearOutputDir> 
       <episode>false</episode> 
       <strict>true</strict> 
       <schemaIncludes> 
        <schemaInclude>*.wsdl</schemaInclude> 
        <schemaInclude>*.xsd</schemaInclude> 
       </schemaIncludes> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

소스를 생성하는 받는다는 명령은 다음과 같습니다 : mvn generate-sources 플러그인을 사용하여 클래스 파일을 생성하려면

는 다음과 같은 구성을 시도합니다.

어떤 클래스를 사용해야합니까?

당신의 경로에서 사용하려면 다음을 시도합니다 (JAXB2 플러그인에 의해 생성)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope" xmlns:ns2="http://tempuri.org/"> 
    <Body> 
     <ns2:Add> 
      <ns2:intA>10</ns2:intA> 
      <ns2:intB>20</ns2:intB> 
     </ns2:Add> 
    </Body> 
</Envelope> 

POJO에 대응 :

protected SoapJaxbDataFormat createDataFormat() { 
    String jaxbPackage = Add.class.getPackage().getName(); 
    ElementNameStrategy elStrat = new TypeNameStrategy(); 
    SoapJaxbDataFormat answer = new SoapJaxbDataFormat(jaxbPackage, elStrat); 
    answer.setVersion("1.2"); 
    return answer; 
} 

@Override 
protected RoutesBuilder createRouteBuilder() throws Exception { 
    return new RouteBuilder() { 
     @Override 
     public void configure() throws Exception { 
      SoapJaxbDataFormat df = createDataFormat(); 
      from("direct:start") // 
       .marshal(df) // 
       .to("mock:result"); 
     } 
    }; 
} 

메시지는이 같은 XML해야한다 :

package org.tempuri.calculator.jaxb2; 

import javax.xml.bind.annotation.XmlAccessType; 
import javax.xml.bind.annotation.XmlAccessorType; 
import javax.xml.bind.annotation.XmlRootElement; 
import javax.xml.bind.annotation.XmlType; 

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "", propOrder = { 
    "intA", 
    "intB" 
}) 
@XmlRootElement(name = "Add") 
public class Add { 

    protected int intA; 
    protected int intB; 

    public int getIntA() { 
     return intA; 
    } 

    public void setIntA(int value) { 
     this.intA = value; 
    } 

    public int getIntB() { 
     return intB; 
    } 

    public void setIntB(int value) { 
     this.intB = value; 
    } 

} 

당신의 pom 파일종속성 :

<dependency> 
    <groupId>org.apache.camel</groupId> 
    <artifactId>camel-soap</artifactId> 
</dependency> 

이 예에서 사용하는 WSDL this unit test에 따라, here를 볼 수 있습니다.

관련 문제