aspose file tools*
The moose likes Web Services and the fly likes web service explorer testing Web service gets right return value, java client gets wrong value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "web service explorer testing Web service gets right return value, java client gets wrong value" Watch "web service explorer testing Web service gets right return value, java client gets wrong value" New topic
Author

web service explorer testing Web service gets right return value, java client gets wrong value

Holly zheng
Greenhorn

Joined: Sep 22, 2009
Posts: 6
I have a bpel project deployed on activebpel server. I use the eclipse web service explorer to test the web service, got right answer. but when I use wsdl2java to generate a client to test the web service, the return value is wrong.

request: int
response: timeInfo (class timeInfo{ private float exeTime; private int invkTimes; ...})

In the client java code, I use response = port.request(3); response.getExeTime() and response.getInvkTimes() to get the return value from the web service and I always get 0.0 and 0.

could this be something wrong related to the encoding method: literal? and _resp = _call.invoke(..) can't recognize the response msg automatically? i don't know. can anyone help?
Holly zheng
Greenhorn

Joined: Sep 22, 2009
Posts: 6
It seems that the bpel web service runs all right and returns right answer, but when the response comes back to the client, something goes wrong. Anyone has any clue? Thanks.



Holly zheng wrote:I have a bpel project deployed on activebpel server. I use the eclipse web service explorer to test the web service, got right answer. but when I use wsdl2java to generate a client to test the web service, the return value is wrong.

request: int
response: timeInfo (class timeInfo{ private float exeTime; private int invkTimes; ...})

In the client java code, I use response = port.request(3); response.getExeTime() and response.getInvkTimes() to get the return value from the web service and I always get 0.0 and 0.

could this be something wrong related to the encoding method: literal? and _resp = _call.invoke(..) can't recognize the response msg automatically? i don't know. can anyone help?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
It sounds like the problem may be related to the data binding.
If you do not manage to solve this in any other way, then you could try to write a web service client that receives and interprets response message itself.
Example:
If you want to use JAXB to do the data binding you use XJC to generate JAXB bean classes from the XML schema describing the message payloads.
In your client, when it receives a response, you use JAXB to unmarshall the payload and thus obtain instance(s) of the JAXB bean classes generated earlier, from which data of the response can be retrieved.

Of course JAXB is just one alternative - if you are happier using StAX, SAX etc. etc. then just go ahead!
Best wishes!
Holly zheng
Greenhorn

Joined: Sep 22, 2009
Posts: 6
I got some clue. Normally both the SOAP Request and Response Envelope should have the namespace that define the complex type. But I can see through eclipse's web service explorer that the SOAP Request&Response sent and received have no namespace prefix. For example,
the CORRECT soap response envelope should be like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<soapenv:Body>
<bpelResponse xmlns:g0 = "http://scheme">
<g0:invkTimes>447</g0:invkTimes>
<g0:executionTime>86.71384</g0:executionTime>
</bpelResponse>
</soapenv:Body>
</soapenv:Envelope>

but what I got is like this:

- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
<invkTimes>447</invkTimes>
<executionTime>86.71384</executionTime>
</soapenv:Body>
</soapenv:Envelope>

with no namespace! So there must be something wrong with my namespace definition.


Ivan Krizsan wrote:Hi!
It sounds like the problem may be related to the data binding.
If you do not manage to solve this in any other way, then you could try to write a web service client that receives and interprets response message itself.
Example:
If you want to use JAXB to do the data binding you use XJC to generate JAXB bean classes from the XML schema describing the message payloads.
In your client, when it receives a response, you use JAXB to unmarshall the payload and thus obtain instance(s) of the JAXB bean classes generated earlier, from which data of the response can be retrieved.

Of course JAXB is just one alternative - if you are happier using StAX, SAX etc. etc. then just go ahead!
Best wishes!
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Just curious, what web service stack do you use and what kind of data binding mechanism?
I usually use JAXB for XML data binding and have never encountered any problems like the ones you are describing.
Best wishes!
Holly zheng
Greenhorn

Joined: Sep 22, 2009
Posts: 6
Hi, Ivan. I don't know much about the techniques you are talking about, sorry. Just say what I know: I use activevos designer design a bpel project, I have to write a .wsdl that describes the process itself (it is where the problem is). When finished, I deploy the bpel project on active-bpel server. Then it is ready to be invoked. When I design the client side, I used wsdl2java automatically getting the frame of the client side, and wrote a client.java to invoke it. Maybe the techniques you mentioned are done automatically somewhere during the process.


here is the wsdl, maybe you can see it through. I didn't add elementFormDefault="qualified" in the schema tag, that's why I encounter the problem: with no namespace specified in the soap msg.

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions
targetNamespace="urn:OrderGoodsProcess1.0"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:lns="urn:OrderGoodsProcess1.0"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns1="http://scheme"
xmlns:tns="urn:OrderGoodsProcess1.0">

<wsdl:types>
<schema targetNamespace="http://scheme" xmlns="http://www.w3.org/2001/XMLSchema"

elementFormDefault="qualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ExecutionTimeInfo">
<sequence>
<element name="exeTime" type="xsd:float"/>
<element name="prgmInvkTimes" type="xsd:int"/>
</sequence>
</complexType>
</schema>
</wsdl:types>

<wsdl:message name="GoodsRequest">
<wsdl:part name="request" type="xsd:int"/>
</wsdl:message>

<wsdl:message name="GoodsResponse">
<wsdl:part name="response" type="tns1:ExecutionTimeInfo"/>
</wsdl:message>

<wsdl:portType name="orderGoodsServicePT">
<wsdlperation name="request">
<wsdl:input message="lns:GoodsRequest"/>
<wsdlutput message="lns:GoodsResponse"/>
</wsdlperation>
</wsdl:portType>

</wsdl:definitions>

Ivan Krizsan wrote:Hi!
Just curious, what web service stack do you use and what kind of data binding mechanism?
I usually use JAXB for XML data binding and have never encountered any problems like the ones you are describing.
Best wishes!
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Take a look at this and see if it helps you:

Best wishes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: web service explorer testing Web service gets right return value, java client gets wrong value