【问题标题】:No endpoint mapping found for..., using SpringWS, JaxB Marshaller没有找到...的端点映射,使用 SpringWS、JaxB Marshaller
【发布时间】:2010-04-29 22:19:48
【问题描述】:

我收到此错误:未找到 [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 映射而不是注释,尽管现在我收到了错误消息。

编辑:更改人员类型

@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;

--其余的是getter和setter。

【问题讨论】:

  • 我也曾在黑暗中拍摄并将 NAMESPACE 常量设置为“{mycompany/coolservice/specs}ChangePerson”,但没有奏效。任何想法/建议这些注释如何工作以选择 ChangePerson,以及我做错了什么......?
  • 您能否也添加ChangePersonType 的源代码,或者至少添加它的前几行。
  • 完成,由jaxb xjc编译器生成。

标签: java jaxb spring-ws


【解决方案1】:

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

原因是

JAXB2 生成的类来自 您的架构有两种风格:那些 有一个@XmlRootElement 注解,可以直接使用 作为参数或响应,以及 那些没有的人。那些类 没有这个注释需要 包裹在 JAXBElement 中。

除了生成的类 您的架构,JAXB2 还会生成一个 ObjectFactory 类,它阐明了 使用 JAXBElement。有一些 工厂方法在那里, 说明如何使用各种 架构类型。

阿尔杰·普茨马 h ttp://forum.springsource.org/showthread.php?t=49817

【讨论】:

  • 请注意,我需要在我的 jaxb:globalBindings 配置中指定 以获取使用 @XmlRootElement 生成的类
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-06
  • 2013-10-10
  • 2018-03-24
  • 1970-01-01
相关资源
最近更新 更多