English 中文(简体)
Spring Web-service unmarhalling not working
原标题:Spring Web-Service unmarshalling not working

我已配置了我的网络服务。

申请案文:

<sws:annotation-driven />    
 <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping" >
<property name="interceptors">
 <list>
    <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
</list>
</property>

注:如果申请提出,拦截器就装上了开端,但却没有写任何东西。

我有一类人服务,其方法是增加个人服务。 一切工程,如果是使用org.dom4j。 作为方法参数的要素;

@Endpoint
public class PersonServiceImpl {
     @PayloadRoot(namespace = "http://www.example.org/person/schema", localPart = "AddPersonRequest")
     @ResponsePayload
       public AddPersonRequest addPersonRequest(@RequestPayload Element element) {
        System.out.println(element.asXML());
        Person response = new Person();
        response.setId(2);
        response.setFirstName("Mad");
        response.setLastName("Mike");
        return response;
     }
}

但是,如果改变我的方法参数,如下文所示(应当使用春季-湿重的自动标识),则请求书。 (JAXB2正在上班)。

The Person-class is annotated with @XMLType and @XMLRootElement.

注:对工作进行罚款。

@Endpoint
public class PersonServiceImpl {
     @PayloadRoot(namespace = "http://www.example.org/person/schema", localPart = "AddPersonRequest")
     @ResponsePayload
       public AddPersonRequest addPersonRequest(@RequestPayload Person request, SoapHeader header) {
        System.out.println(header.getName());
        System.out.println(request.getFirstName());
        Person response = new Person();
        response.setId(2);
        response.setFirstName("Mad");
        response.setLastName("Mike");
        return response;
     }
}

Person.java:

@XmlType
@XmlRootElement(namespace="http://www.example.org/person/schema", name="Person")
public class Person implements Serializable {

    private int id;
    private String firstName;
    private String lastName;

    @XmlElement
    public String getFirstName() {
        return firstName;
    }
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    @XmlElement
    public String getLastName() {
        return lastName;
    }
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    @XmlAttribute
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
}

通过肥皂倡议发出的测试请求(由湿租赁产生):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.example.org/person/schema"> 
<soapenv:Header/>
<soapenv:Body>

  <sch:AddPersonRequest>

     <sch:Person sch:Id="1">

        <sch:FirstName>firstname</sch:FirstName>

        <sch:LastName>lastname</sch:LastName>

     </sch:Person>

  </sch:AddPersonRequest>

</soapenv:Body>
</soapenv:Envelope>
最佳回答

You mentioned marshalling is working I don t see any reason why unmarshalling won t work, Have you tested marshall and unmarshall in isloation?

有理由确保申请是好的, 您能够增加伐木拦截器,并印刷用户访问网络服务的实际要求,在您的背景档案中添加这一标记。

  <sws:interceptors>
    <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor">
        <property name="logRequest" value="true"></property>
        <property name="logResponse" value="true"></property>
    </bean>
</sws:interceptors>

你们应当看到一个像包含整个肥皂要求的标志性信息,我还要加上一个全心全心全心全书的标识要求。

   DEBUG [http-8080-2]:endpoint.interceptor.SoapEnvelopeLoggingInterceptor.logMessage - Request:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://hoost:port/context/patient/schemas">
      <soapenv:Header/>
         <soapenv:Body>
            <sch:addRequest>
              <sch:patient>
                  <sch:id>?</sch:id>
                     <sch:lastname>Joe</sch:lastname>
                </sch:patient>
             </sch:addRequest>
        </soapenv:Body>
      </soapenv:Envelope>

UPDATE of answer

或许是你的要求,但不能确定

        <sch:FirstName>firstname</sch:FirstName> (this should be)

        <sch:firstName>firstname</sch:firstName>

另一项更新

例外情况是由于你界定了终点,在您的肥皂要求中(sch:AddPersonRequest),你正在寄发一张非个人的有效载荷,从而改变终点,以反映:@RequestPayload should be AddPersonRequest not Person

     @PayloadRoot(namespace = "http://www.example.org/person/schema", localPart = "AddPersonRequest")
     @ResponsePayload
      public AddPersonRequest addPersonRequest(@RequestPayload AddPersonRequest request, SoapHeader header) {
问题回答

我不敢肯定,你是否仍然需要回答,看你的最新评论。 我很想像你的要求和反应有效载荷。 他们似乎被转用。 不管怎么说,这很难说没有人阶级。

我先讨论过类似的问题,然后通过增加日本宇宙航空研究开发机构技术研究组,解决了这些问题。 和本信一样:

@PayloadRoot(
    localPart = "PutOrganisationUnitRequest", 
    namespace = DEFAULT_NAMESPACE
)
@ResponsePayload public JAXBElement<Response> putOrganisationUnits (
    @RequestPayload JAXBElement<PutOrganisationUnitRequest> organisations,
    MessageContext messageContext) {

您可以检查的另一件事是贵格勃班子的名称空间和您的终点定义。

这一春天网络服务的实施是完全的垃圾。 脑后死亡的辅助器能比“pros”更好地发挥作用。

仅仅遵循“智者”原则,在根植型后恢复树,是多么困难。

NO-ONE需要这些名称空间。 从来没有发生过同一要求有两个内容,名称相同,但来自不同的名称空间。 但是,这些名称空间是无休止的痛苦。

仅将XML元素与野外相匹配。 这只需要什么。 如果任何人在收回财产时照顾到他们,但当一项请求时却完全忽视他们,那么,从SDL那里指定出国名。

When I look at all of this I really want to spend a month and do a NORMAL SOAP webservice framework with XML serialization/deserialization that only cares about element names and auto instantiate request/response objects as long as XML tree is matching object tree.





相关问题
IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

ASP.net web services

I am using a web service which sets the Thread.CurrentPrincipal object while logging in and soon later when another webmethod of the same web service accesses Thread.CurrentPrincipal, its different/...

Unity Container Disposing and XML Web Service

I am registering some wrapers over un-managed objects in container. How can I dispose of them at the end of the container s lifetime? Please bear in mind I have an XML Web service.

SharePoint : web service permission error

I have a sharepoint site, and I am calling a standard sharepoint web service. I create the web service request like this : wsDws.Url = this.SiteAddress + @"/_vti_bin/Dws.asmx"; When I use ...

热门标签