0

This post is the closest one to my problem. However, there is no explanation there how the problem was solved or what was really wrong with it.

I've tried a very basic configuration to eliminate any underlying issues.

My spring-ws-context.xml is this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:sws="http://www.springframework.org/schema/web-services"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd">
<context:component-scan base-package="test" />

<sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller" />

<sws:dynamic-wsdl id="person" portTypeName="Person"
    locationUri="/personService/" targetNamespace="http://myschema/person/definitions">
    <sws:xsd location="classpath:person.xsd" />
</sws:dynamic-wsdl>
<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>

<oxm:jaxb2-marshaller id="marshaller">
    <oxm:class-to-be-bound name="test.request.GetPersonRequest" />
</oxm:jaxb2-marshaller>

My GetPersonRequest.java is this

@XmlRootElement(name = "GetPersonRequest", namespace = PersonEndpoint.NAMESPACE_URI)
@XmlAccessorType(XmlAccessType.FIELD)
public class GetPersonRequest {
    @XmlElement
    private Integer id;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

}

My Endpoint is this:

@Endpoint
public class PersonEndpoint {

    public static final String NAMESPACE_URI = "http://myschema/person/schemas";

    @Autowired
    PersonService service;

    @PayloadRoot(namespace = NAMESPACE_URI, localPart="GetPersonRequest")
    public @ResponsePayload GetPersonResponse handleGetPersonRequest(@RequestPayload Element request) {
        System.out.println("handleGetPersonRequest()");
        // TODO: Go to service.getPerson(request)
        return new GetPersonResponse();
    }
}

I would like to note that the entire service is up and running fine with no errors. This is what's okay so far (as per the instructions above):

1) Endpoint can display wsdl to soapui and browser.

2) soap xml can be submitted with no errors.

3) log files show the xml body was being sent.

But for the life of me @RequestPayload GetPersonRequest request is blank! It only has one field for chrissakes and it won't even get set!

Now, if I don't use JAXB as the request object but use org.w3c.dom.Element instead I can see that all the data I submitted is all there.

What am I missing? I can't help but think I'm missing something completely simple.

This is the sample input by the way (at least what the logs show):

  <sch1:GetPersonRequest xmlns:sch1="http://myschema/person/schemas">
     <sch1:id>1</sch1:id>
  </sch1:GetPersonRequest>
Community
  • 1
  • 1
Chad
  • 738
  • 2
  • 8
  • 21
  • you may ignore the marhaller declaration as I added it later for testing purposes – Chad Oct 04 '13 at 19:11
  • Okay this is weird. Apparently, explicitly declaring the namespace on XmlElement fixes the issue. But I'm thinking it shouldn't be like that. I've worked on a plain soap project and this doesn't do that or require it at all. – Chad Oct 04 '13 at 20:07

1 Answers1

0

I can't find a better solution for this. So far the only answer I can come up with is using a package-info.java

@javax.xml.bind.annotation.XmlSchema(namespace = test.ws.PersonEndpoint.NAMESPACE_URI, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package test.request;

My older project didn't use spring and spring REQUIRES the xsd file to have a targetNamespace attribute. I wanted to simplify my current app by doing with namespaces at the moment but it appears that won't work with spring-ws.

Chad
  • 738
  • 2
  • 8
  • 21