使用 SpringWS、JaxB Marshaller 找不到端点映射...

发布于 2024-08-30 13:10:02 字数 3591 浏览 3 评论 0原文

我收到此错误:找不到 [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);
}

我对 WebServices 非常陌生,并且

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

}

对注释不太满意。我正在关注有关在 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;

--其余的是 getter 和 setter。

I get this error: No endpoint mapping found for [SaajSoapMessage {http://mycompany/coolservice/specs}ChangePerson]

Following is my ws config file:

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

I have then the following files:

public interface MarshallingPersonService {

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

public RespondPersonType changePerson(ChangePersonType request);
}

and

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

}

I am pretty much new to WebServices, and not very comfortable with annotations. I am following a tutorial on setting up jaxb marshaller in springws. I would rather use xml mappings than annotations, although for now I am getting the error message.

EDIT: 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;

--The rest are getters and setters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春花秋月 2024-09-06 13:10:02

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

原因是

JAXB2 生成的类
你的模式有两种风格:
有一个@XmlRootElement
注解,可以直接使用
作为参数或响应,以及
那些没有的人。那些课程
还没有这个注释需要
包装在 JAXBElement 中。

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

阿尔扬·普茨马
http://forum.springsource.org/showthread.php?t=49817

I solved it. The parameter of the end point class and return variable had to be wrapped in JAXBElement, like JAXBElement.

The reason is

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文