Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Improving the spring-ws client

  1. #11

    Default

    I'm a situation where I can either
    a) keep using one (un)marshaller on the server and client (using Spring-WS for both)
    b) switch to SAX/StAX but not sure how that will play out on the client
    c) wait for the client to support multiple (un)marshallers

    I'd like to go for c. I'd like to help with this feature but I'd need some direction as to how you would like the architecture. Let me know your thoughts.

  2. #12
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Theoretically, you can use multiple marshallers yourself right now, by inject the marshallers your own class, and using them directly in the callback. Take a look at the source code of WebServiceTemplate, and see that the marshal* methods are nothing more than convenience methods for the generic sendAndReceive() method.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #13

    Default

    So I see

    Code:
    public void doWithMessage(WebServiceMessage request) throws IOException, TransformerException {
                    MarshallingUtils.marshal(getMarshaller(), requestPayload, request);
                    if (requestCallback != null) {
                        requestCallback.doWithMessage(request);
                    }
                }
    @line 258 in WebServiceTemplate. So really I have to do is something to the affect of:

    Code:
    private List<Marshaller> marshallers;
    private List<Unmarshaller> unmarshallers;
    ...
    public void doWithMessage(WebServiceMessage request) throws IOException, TransformerException {
                    for (Marshaller marshaller : marshallers) {
                        MarshallingUtils.marshal(marshaller, requestPayload, request);
                        if (requestCallback != null) {
                            requestCallback.doWithMessage(request);
                        }
                    }
    And the same for the unmarshallers. Is this right?

  4. #14
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Yup, something like that. I'm not sure if you want to iterate over all the marshallers in order, that seems a bit weird.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  5. #15

    Default

    How else would I do it? Use reflection to determine the package name and use the appropriate (un)marshallers? I mean I'll end up having at least two (un)marshallers in every operation.

  6. #16
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Well, you could do:

    Code:
    private List<Marshaller> marshallers;
    private List<Unmarshaller> unmarshallers;
    ...
    public void doWithMessage(WebServiceMessage request) throws IOException, TransformerException {
        for (Marshaller marshaller : marshallers) {
            if (marshaller.supports(requestPayload.getClass())) {}
                MarshallingUtils.marshal(marshaller, requestPayload, request);
                if (requestCallback != null) {
                    requestCallback.doWithMessage(request);
                }
                break;
            }
        }
    }
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  7. #17

    Default

    I would have to make at least 2 passes at marshalling. One for the *Request & *Response objects, and one for the value(s) in the *Request & *Response.

    So wouldn't it be something like:

    Code:
    private List<Marshaller> marshallers;
    private List<Unmarshaller> unmarshallers;
    ...
    public void doWithMessage(WebServiceMessage request) throws IOException, TransformerException {
        for (Marshaller marshaller : marshallers) {
            if (marshaller.supports(requestPayload.getClass())) {
                MarshallingUtils.marshal(marshaller, requestPayload, request);
            }
        }
        if (requestCallback != null) {
            requestCallback.doWithMessage(request);
        }
    }

  8. #18

    Default

    Plus I'm not sure how the unmarshalling would work since I don't have a responsePayload

  9. #19

    Default

    I've tried playing with extending WebServiceTemplate but ran into problems. I'll just have to wait until the client officially supports multiple (un)marshallers.

  10. #20

    Default

    So I noticed that in revision 8931, there was a change in org.springframework.oxm.jaxb.AbstractJaxbMarshalle r that allows contextPaths. Does that mean I can now have one JAXBMarshaller handle multiple packages? Both for server & client? This would really help me out.

    EDIT:
    I have confirmed that this works. This is great! I now have separate packages for my request/response objects for each web service yet one marshaller/unmarshaller.
    Last edited by mmccaskill; Nov 26th, 2007 at 08:15 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •