• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

client code to connect to Web services

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to develop a web service(my first) using the top down approach.
I was able to develop,validate and deploy the service.
How do I create a client the working of the service.

I know that at first you get an instance of the service locator..ie
MyWSDLFile_ServiceLocator test=new MyWSDLFile_ServiceLocator();

But after that I couldnt get the stub of the service as ServiceLocator does not have the appropriate get.... function..I hope I am clear.

Cheers,
Sam
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the service is up and running, then the SOAP server generally publish its WSDL (often at the URL of the service with an appended "?WSDL").

Armed with the WSDL, you should be able to create client-side code by using a tool of whatever SOAP toolkit you're using; it might be called "wsdl2java" or something. That will create all the Java classes necessary to access the service.
 
sam barker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My bad ....you are correct.I ran that,then wrote a client.it looks like something like this...

MyWSDLFileSOAPStub x= new MyWSDLFileSOAPStub();
String z=x.myFirst("ho", "srte");//garbage arguments
System.out.println(z);



But when I run this I am getting an exception.....


Exception in thread "main" AxisFault
faultCode: {http://xml.apache.org/axis/}Server.NoEndpoint
faultSubcode:
faultString: No endpoint
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}exceptionName rg.apache.axis.NoEndPointException
{http://xml.apache.org/axis/}stackTrace:No endpoint
at org.example.www.MyFirstWSDL.MyFirstWSDLSOAPStub.myFirst(MyFirstWSDLSOAPStub.java:94)
at MyFirstClient.main(MyFirstClient.java:10)
at org.example.www.MyFirstWSDL.MyFirstWSDLFileSOAPStub.myFirst(MyFirstWSDLSOAPStub.java:94)

=========================================================================
The exception is thrown because super.cacheendpoint is null

public java.lang.String myFirst(java.lang.String time, java.lang.String loc) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[0]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("http://www.example.org/MyFirstWSDLFile/MyFirst");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://www.example.org/MyFirstWSDLFile/", "MyFirst"));

setRequestHeaders(_call);
setAttachments(_call);
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {time, loc});

if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
}
else {
extractAttachments(_call);
try {
return (java.lang.String) _resp;
} catch (java.lang.Exception _exception) {
return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class);
}
}
} catch (org.apache.axis.AxisFault axisFaultException) {
throw axisFaultException;
}

Cheers,
Sma
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to make sure, you did replace the two example.org URLs with the URLs of your web service, right?
[ August 15, 2008: Message edited by: Ulf Dittmer ]
 
sam barker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No but I have changed it now.
I changed the SOAP:address in my WSDL file

<soap:address location="http://localhost:8080/axis/services/MyFirstWSDLFileSOAP"/>

But after compiling the server and client code I am still getting the same error..
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And you are getting the same error after you regenerate the WSDL code? You will need to do that as well, not just a recompile.
 
sam barker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah I had regenerated the client and server side.
But the SOAP operation is still
wsdlsoap peration soapAction="http://www.example.org/MyFirstWSDLFile/MyFirst"/>

Is that alright
 
sam barker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved the problem.I should have been using the service locator to connect.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sam barker wrote:Solved the problem.I should have been using the service locator to connect.



hi do you have the code of your solution?
 
Men call me Jim. Women look past me to this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic