Skip to main content

JAX-WS Returning Mode.IN Argument as Result Instead of Actual @WebResult

3 replies [Last post]
Joined: 2009-01-05

I've been working on this problem for some time, and just can't figure out what is going on. To begin with, I have a legacy service (in Spring) that uses XMLBeans to marshal/unmarshal the XML data. I am using the Spring extension to JAX-WS to define my SEI and wire in the existing service. I can invoke the newly created web service just fine, and recover the XML from the input argument, which in the SEI is declared as Holder<?>; this turns out to be of type Element, so I am able to extract the XML. From there I execute my service and attempt to set the result/return value, which is defined as Holder. The client never sees the newly created XML response; it always gets the original input argument back as the return value. When I stepped through the code as it executes, inside of it drops the actual result object, and uses the existing input argument instead to put into the response Message object.

Would somebody please take a look at the following WSDL and SEI to let me know what I'm doing wrong? I'm completely out of ideas as to what to do right now. I suspect it has something to do with the fact that the input argument and return object are both of the same type. Originally I defined this web service in the WSDL to have an IN/OUT argument so the result would be returned that way, but the same thing happened. I broke it out to a single input argument and separate return object as my first attempt around this problem.

Thanks in advance.


<br />
<?xml version="1.0" encoding="UTF-8"?></p>


<br />
@WebService(serviceName="CAD2CAD")<br />
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)<br />
public class CAD2CADServiceEndpoint extends SpringBeanAutowiringSupport<br />
<p>    /** Concrete implementation of the underlying service's business logic */<br />
    @Autowired<br />
    private CAD2CADServiceImpl m_Service = null ;</p>
<p>    @WebMethod(operationName="UnitStatusUpdate")<br />
    @WebResult(partName="result", name="UnitStatusUpdate", targetNamespace="http://leitsc-lib/2.0/1.0/doc/UnitStatusUpdate")<br />
    public unitStatusUpdate(<br />
            @WebParam(partName="parameters", name="UnitStatusUpdate", mode=WebParam.Mode.IN, targetNamespace="http://leitsc-lib/2.0/1.0/doc/UnitStatusUpdate")<br />
  <?> a_Request<br />
            )<br />
    {<br />
        Holder result = null ;</p>
<p>	// Extract raw XML from request argument<br />
        Element value = (Element)a_Request.value ;<br />
        Document doc = value.getOwnerDocument() ;<br />
        String xml = XmlUtilities.documentToXml( doc ) ;</p>
<p>	// Execute the actual service; marshal/unmarshal occurs within this method call<br />
        String statusResult = this.m_Service.unitStatusUpdate( xml ) ;</p>
<p>	// Put raw XML response into Document for return<br />
        doc = XmlUtilities.xmlToDocument( statusResult ) ;<br />
        result = new Holder( doc ) ;</p>
<p>        return result ;<br />
    }<br />
}<br />

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-07-16

I've had to do something similar where I passed in an XML as a param and sent the XML back. I -just- got this working, so, while you've already got a solution, there is a somewhat more elegant way to try (possibly?). Here's what I did:

You may be able to do everything in handlers, then just take in strings (that you can convert to Documents) if that's what you prefer. Feel free to contact me if you are interested in the approach and have more questions. Simply reply to this thread or the thread I'm linked to (I'm 'watching' both of them), and I'll get back to you.

Joined: 2009-01-05

Since I never got any feedback on this I simply went ahead and implemented the SEI using a JAXB generated class as my argument and return type. Obviously, this worked just fine, but forced me to marshal/unmarshal between JAXB and XMLBeans versions of the entities. This is not a desirable solution given the extra overhead of serializing/deserializing multiple times within each call.

I still would like to hear from the developers how I can successfully use a Holder object as the input argument and return value as originally described. It seemed to work for the input, but lead to problems. The problems persisted even after updating JAXB to version 2.1.9. If I could successfully bypass JAXB within my SEI, then it would be a straightforward set of steps to plug in my XMLBeans binding layer for marshalling.



Joined: 2003-06-14

Actually, the generated SEI seems to be wrong(returning Holder) Can you create a simple test case with WSDL and schema. Schema is required as this is a wrapper style.