java - 未找到端点映射...,使用 SpringWS、JaxB Marshaller

标签 java jaxb spring-ws

我收到此错误:未找到 [SaajSoapMessage { http://mycompany/coolservice/specs 的端点映射}改变人]

以下是我的 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;        
    }

}

我对 Web 服务还很陌生,对注释不是很熟悉。我正在关注有关在 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。

最佳答案

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

原因是

The classes generated by JAXB2 from your schema come in two flavors: those that have a @XmlRootElement annotation, which can be used directly as either parameter or response, and those who haven't. Those classes which haven't got this annotation need to be wrapped in a JAXBElement.

Besides the generated classes from your schema, JAXB2 also generates an ObjectFactory class, which clarifies the use of JAXBElement. There are some factory methods is there, which illustrate how you can use the various schema types.

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

关于java - 未找到端点映射...,使用 SpringWS、JaxB Marshaller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2736220/

相关文章:

java - 在appengine中追溯分配关键范围

JAXB:限定属性禁用默认命名空间 xmlns =""?

java - 使用 JAXB 保持 DRY

java - 如何将 'webservice credentials' 传递到我的网络服务端点?

java - 自定义 Jackson 对象映射器

java - 数学方程转换

java - Spring WS 2.1.0 : Endpoint interceptors order

wsdl - 来自 WSDL 的 Spring-ws 客户端

java - 在java中把_放在变量前面有什么意义?

java - JAX-B定制的XML输出