| View previous topic :: View next topic |
| Author |
Message |
ravikb_netbeans
Joined: 17 Sep 2008 Posts: 4
|
Posted: Wed Sep 17, 2008 4:56 am Post subject: Jax-WS Client |
|
|
Hi,
I have published a simple webservice , which has webmethod called displayName(String name). service is published and running in glashfishv2 server.
I have created a Standalone dii client ( JAX-WS Style) to invoke the service.
In the code i have used javax.xml.ws.Dispatch to invoke the service.
Now the issue is, I am able to call the service but the paramenter value which i have passed is not reaching the service operation. It is taking null at service side.
Code snippet at Service Side:
=====================
@WebMethod(operationName = "displayName")
public String displayName(@WebParam(name = "name")
String name)
{
System.out.println("ConverterService: Hello :"+name);
return "Hello: "+name;
}
Code snippet at Client Side:
==================
wtp.ConverterWSService service = new wtp.ConverterWSService();
QName portQName = new QName("http://wtp/", "ConverterWSPort");
String req = "<celsiusToFarenheit xmlns=\"http://wtp/\"><celsius>11</celsius></celsiusToFarenheit>";
try {
// Call Web Service Operation
Dispatch<Source> sourceDispatch = null;
sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
Source result = sourceDispatch.invoke(new StreamSource(new StringReader(req)));
please help in solving this issue.
Thanks in advance.
ravi |
|
| Back to top |
|
 |
Manuel Mall Posted via mailing list.
|
Posted: Wed Sep 17, 2008 8:39 am Post subject: Jax-WS Client |
|
|
You seem to be using a slightly unconventional way of invoking the web
service and I have no idea if it will ever work as I never used this style.
However, your XML and your web method definition don't seem to match. The
web method is called displayName but you seem to be calling something called
celsiusToFarenheit. Same applies to the argument.
The more common invocation strategy for a web service is to construct the
service, then get the port from the service and then invoke the operation on
the port. In your case something like
new
wtp.ConverterWSService().getNameOfPortInYourWsdl().celsiusToFahrenheit("11")
;
This assumes that ConverterWSService is the web service client code as
generated from the WSDL by the wsimport tool that comes with JAX-WS.
Manuel
| Quote: | -----Original Message-----
From: ravikb_netbeans [mailto:address-removed]
Sent: Wednesday, 17 September 2008 12:57 PM
To: address-removed
Subject: [nbj2ee] Jax-WS Client
Hi,
I have published a simple webservice , which has webmethod called
displayName(String name). service is published and running in glashfishv2
server.
I have created a Standalone dii client ( JAX-WS Style) to invoke the
service.
In the code i have used javax.xml.ws.Dispatch to invoke the service.
Now the issue is, I am able to call the service but the paramenter value
which i have passed is not reaching the service operation. It is taking
null at service side.
Code snippet at Service Side:
=====================
@WebMethod(operationName = "displayName")
public String displayName(@WebParam(name = "name")
String name)
{
System.out.println("ConverterService: Hello :"+name);
return "Hello: "+name;
}
Code snippet at Client Side:
==================
wtp.ConverterWSService service = new wtp.ConverterWSService();
QName portQName = new QName("http://wtp/", "ConverterWSPort");
String req = "<celsiusToFarenheit
xmlns=\"http://wtp/\"><celsius>11</celsius></celsiusToFarenheit>";
try {
// Call Web Service Operation
Dispatch<Source> sourceDispatch = null;
sourceDispatch = service.createDispatch(portQName,
Source.class, Service.Mode.PAYLOAD);
Source result = sourceDispatch.invoke(new StreamSource(new
StringReader(req)));
please help in solving this issue.
Thanks in advance.
:D ravi
|
|
|
| Back to top |
|
 |
ravikb_netbeans
Joined: 17 Sep 2008 Posts: 4
|
Posted: Wed Sep 17, 2008 9:47 am Post subject: |
|
|
Thank for your reply,
sorry i have not give complete service code there, i have the other web method also.
Code at Service Side:
==============
@WebMethod(operationName = "celsiusToFarenheit")
public float celsiusToFarenheit(@WebParam(name = "celsius")
float celsius) {
//TODO write your implementation code here:
System.out.println("ConverterService: celsiusToFarenheit :"+celsius);
return (celsius * 9 / 5) + 32;
}
I have tried with the code what you have suggested and I got the response.
new wtp.ConverterWSService().getConverterWSPort().celsiusToFarenheit(11.00f);
but i would like to know, how feasible if i use Dispatch.
dispatch is the other way (dynamic invocation interface-If an application does not know the interface or WSDL at design time, it can still invoke the service by getting the WSDL at runtime) to invoke the jax-ws web service.
with this approach only, i am getting an issue as I mentioned earlier. |
|
| Back to top |
|
 |
bushra
Joined: 16 Sep 2008 Posts: 9
|
Posted: Wed Sep 17, 2008 11:23 am Post subject: wud u plz help me? |
|
|
ravikb,
sorry that instead of replyin ur post, im asking you to help me in something. would you plz tell me where can we see the result sent back by our web service?
i have made a BPEL, and have made a jsf app. clicking on a button on my jsp page, an operation is called on the wsdl. now the problem is that i dunno where to see my result sent back by my BPEL.
plz help me out.
regards, |
|
| Back to top |
|
 |
ravikb_netbeans
Joined: 17 Sep 2008 Posts: 4
|
Posted: Wed Sep 17, 2008 11:34 am Post subject: |
|
|
I know TaskManager API of Websphere to invoke a process.
could you provide more infor about your BPEL implementation ans jsf stuff? where jsf & bpel engine are running? |
|
| Back to top |
|
 |
bushra
Joined: 16 Sep 2008 Posts: 9
|
Posted: Wed Sep 17, 2008 5:05 pm Post subject: |
|
|
thanks,
im using netbeans 6.1, n the server that i went for is glassfish v2. jsf and bpel both are running on the same system. i made a bpel project. and then a visual web jsf project. in the latter i added a web service client, providing location of entry-level wsdl for that bpel. then i called the operation of that wsdl on the button added to the jsp page (by right clicking and selecting WEB SERVICE CLIENT RESOURCES and then CALL WEB SERVICE OPERATION).
i have a text field. the user will enter h/her contact number. the bpel will check it against a hard-coded value. if its same, the bpel sends back "duplicating", and if not its sends "nonduplicating". i have a static text field on that jsp page. i wanted to set its value according to the result.
the action on button is as follows: (and plz lemme know if i have passed the parameters in the right way . its in bold)
| Code: |
public String button1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
QName portQName = new QName("http://j2ee.netbeans.org/wsdl/testWSDL" , "testWSDLPort");
String req = "<callCheckDuplicationOperation xmlns=\"http://j2ee.netbeans.org/wsdl/testWSDL\"><part1[b]>}#{Page1.textField3}[/b]</part1></callCheckDuplicationOperation>";
try { // Call Web Service Operation
Dispatch<Source> sourceDispatch = null;
sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
Source result = sourceDispatch.invoke(new StreamSource(new StringReader(req)));
} catch (Exception ex) {
// TODO handle custom exceptions here
}
return null;
} |
there are no errors, but i dont know where to look for the result sent back by that wsdl operation (of that bpel). or how to set the staticTEXT field according to it.
thanks again.
regards, |
|
| Back to top |
|
 |
bushra
Joined: 16 Sep 2008 Posts: 9
|
Posted: Wed Sep 17, 2008 5:14 pm Post subject: |
|
|
sorry ravikb, my input cudnt be bold in my last post. i was refering to #{Page1.textField3} in the following line of code.plz temme if i've sent the value of text field in the right way.
String req = "<callCheckDuplicationOperation xmlns=\"http://j2ee.netbeans.org/wsdl/testWSDL\"><part1>}#{Page1.textField3}</part1></callCheckDuplicationOperation>";}
actually this project is my test app. im developing an open source CRM for product-based software houses. its bpel modules are quite complex, thats why i made a test app and am trying to call its operation from a test jsf app. i havnt read much abt jsf, as i were working on bpel and composite apps. i searched alot on how to call a wsdl operation but cudnt find any helpful example.
i wud really be thankful to you if u help me as it wud rilli help me alot in my actual project.
regards, |
|
| Back to top |
|
 |
ravikb_netbeans
Joined: 17 Sep 2008 Posts: 4
|
Posted: Thu Sep 18, 2008 5:08 am Post subject: |
|
|
i think this will be helpful to see your response/result on console:
Result streamResult = new StreamResult(System.out);
System.out.println("*********result*********");
// run the transform
TransformerFactory.newInstance().newTransformer().transform(result, streamResult); |
|
| Back to top |
|
 |
bushra
Joined: 16 Sep 2008 Posts: 9
|
Posted: Thu Sep 18, 2008 9:45 am Post subject: |
|
|
thanks,
but could you plz tell me how can i set my static text field's value equal to the string sent back my bpel on my jsp page?? |
|
| Back to top |
|
 |
|