没有找到...的端点映射,使用SpringWS,JaxB Marshaller

时间:2010-04-29 09:43:21

标签: java jaxb spring-ws

我收到此错误:找不到[SaajSoapMessage {http://mycompany/coolservice/specs} ChangePerson]的端点映射

以下是我的ws配置文件:

<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
    <description>An endpoint mapping strategy that looks for @Endpoint and @PayloadRoot annotations.</description>
</bean>
<bean class="org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter">
    <description>Enables the MessageDispatchServlet to invoke methods requiring OXM marshalling.</description>
    <constructor-arg ref="marshaller"/>
</bean>

<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    <property name="contextPaths"> 
    <list>
        <value>org.company.xml.persons</value>
        <value>org.company.xml.person_allextensions</value>
        <value>generated</value>
    </list>
    </property>
</bean>


<bean id="persons" class="com.easy95.springws.wsdl.wsdl11.MultiPrefixWSDL11Definition">   
    <property name="schemaCollection" ref="schemaCollection"/>                                               
    <property name="portTypeName" value="persons"/>                                
    <property name="locationUri" value="/ws/personnelService/"/>                              
    <property name="targetNamespace" value="http://mycompany/coolservice/specs/definitions"/>       
</bean>

<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">                   
    <property name="xsds">
    <list>
        <value>/DataContract/Person-AllExtensions.xsd</value>
        <value>/DataContract/Person.xsd</value>
    </list>
    </property>
     <property name="inline" value="true"/>      
</bean>

我有以下文件:

public interface MarshallingPersonService {

public final static String NAMESPACE = "http://mycompany/coolservice/specs";
public final static String CHANGE_PERSON = "ChangePerson";

public RespondPersonType changePerson(ChangePersonType request);
}

  @Endpoint
  public class PersonEndPoint implements MarshallingPersonService {

    @PayloadRoot(localPart=CHANGE_PERSON, namespace=NAMESPACE)
    public RespondPersonType changePerson(ChangePersonType request) {
        System.out.println("Received a request, is request null? " + (request == null ? "yes" : "no"));
        return null;        
    }

}

我对WebServices很陌生,对注释不太满意。我正在关注在springws中设置jaxb marshaller的教程。我宁愿使用xml映射而不是注释,尽管现在我收到错误消息。

编辑:ChangePersonType

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ChangePersonType", propOrder = {
"applicationArea",
"dataArea"
})
public class ChangePersonType {

@XmlElement(name = "ApplicationArea", namespace = "http://mycompany/coolservice/specs", required = true)
protected TransApplicationAreaType applicationArea;
@XmlElement(name = "DataArea", namespace = "http://mycompany/coolservice/specs", required = true)
protected DataArea dataArea;
@XmlAttribute(required = true)
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected String releaseID;
@XmlAttribute
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected String versionID;

- 其余的是吸气者和制定者。

1 个答案:

答案 0 :(得分:1)

我解决了。终点类和返回变量的参数必须包装在JAXBElement中,就像JAXBElement一样。

原因是

  

JAXB2从中生成的类   您的架构有两种形式:那些   有一个@XmlRootElement   注释,可以直接使用   作为参数或响应,和   那些没有的人。那些课程   没有这个注释需要   包装在JAXBElement中。

     

除了生成的类   你的架构,JAXB2也会生成一个   ObjectFactory类,它澄清了   使用JAXBElement。有一些   工厂方法就在那里   说明如何使用各种   模式类型。

     

Arjen Poutsma   h ttp://forum.springsource.org/showthread.php?t = 49817