Announcement Announcement Module
Collapse
No announcement yet.
Improving the spring-ws client Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • jpeterson
    started a topic Improving the spring-ws client

    Improving the spring-ws client

    I have been tracking spring-ws for a while and I am beginning to use it pretty extensively. One thing that keeps coming up is that the web-service client support (imho) could use some improvement. I wanted to float the idea of trying to refactor the client package to be less complicated, more capable, and easier to use. I've got an idea for how to do that and, with Arjen's permission, I would like to submit it as a contribution.

    As an intellectual exercise for myself I have already done a good portion of the refactoring work. But before I submit it or do any more work I wanted to get a feeling for what other people thought. Is this something that would be valuable?

  • Arjen Poutsma
    replied
    Yeah, I added that explicit feature. Silly of me not to mention it here. It was available in the past as well, though you had to do it by hand (i.e. create one colon separated context path from multiple package names, like so: com.acme.foo:com.acme.bar

    Leave a comment:


  • mmccaskill
    replied
    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, 09:15 AM.

    Leave a comment:


  • mmccaskill
    replied
    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.

    Leave a comment:


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

    Leave a comment:


  • mmccaskill
    replied
    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);
        }
    }

    Leave a comment:


  • Arjen Poutsma
    replied
    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;
            }
        }
    }

    Leave a comment:


  • mmccaskill
    replied
    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.

    Leave a comment:


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

    Leave a comment:


  • mmccaskill
    replied
    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?

    Leave a comment:


  • Arjen Poutsma
    replied
    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.

    Leave a comment:


  • mmccaskill
    replied
    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.

    Leave a comment:


  • Arjen Poutsma
    replied
    Yes, this will probably include the possibility of multiple marshallers.

    Leave a comment:


  • mmccaskill
    replied
    Do these proposed changes include support for multiple marshallers? The problem I'm running into is I need to have multiple marshallers/adapters on the server (which it does) but I cannot replicate that on the client. Until then I have to shove 30! objects into the same package.
    Last edited by mmccaskill; Nov 4th, 2007, 03:17 PM. Reason: grammar

    Leave a comment:


  • Arjen Poutsma
    replied
    Thanks for the code. It looks interesting!

    Unfortunately, we are too far in the 1.0 release cycle to add this new feature now. We will probable add it in the post 1.0 timeframe, either in a minor update (1.0.x), or - more likely - 1.1.

    Remember, if you want to see this functionality in SWS as soon as possible, vote for the issue!

    Leave a comment:

Working...
X