• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Creating web service client

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to create a web service client in Java. I've gotten this far:

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

import java.net.*;

public class WebServiceClient {

public void connect() throws Exception
{
Service service = new Service();
Call call = (Call)service.createCall();

String endpoint = "http://ajax.syr.edu/causp/kt/ktWebservice.asmx?wsdl";
call.setTargetEndpointAddress(new URL(endpoint));
call.setOperationName(new QName("Login"));

String username = "bond";
String password = "bond";
boolean guestMode = false;

System.out.println("username: " + username + "\tpassword: " + password);
Integer SID = (Integer)call.invoke(new Object [] {new String(username), new String(password), new Boolean(guestMode)});
System.out.println("username: " + username + "\tpassword: " + password);

System.out.println("Got result : " + SID);

}

public static void main(String [] args)
{

WebServiceClient w = new WebServiceClient();

try
{
w.connect();
}

catch(Exception e)
{
System.out.println("An error has occurred.");
e.printStackTrace();
}

System.out.println("Done");

}
}


I code compiles, but when I run it, I get:
AxisFault
faultcode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.net.SocketException: Software caused connection abort: connect
faultActor:
faultNode:
faultDetail:
<http://xml.apache.org/axis/}stackTrace: java.net.SocketException: Software caused connection abort: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImp.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImplet.java:171)
...
...
...

Can anyone decipher this for me? Or maybe give me an easier way to create a web services client? Thanks!

Evan
 
Ranch Hand
Posts: 548
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are u able to get any browser when you type http://ajax.syr.edu/causp/kt/ktWebservice.asmx?wsdl in browser ?

easiest way is to use a IDE like IBM WSAD or plug in to Eclipse ...
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you should use some tool to geanerate webservice proxy class from WSDL file such as

- Lomboz : SOAP Client
- Websphere
- etc...

All tools make it easy to you.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Evan McCarthy:
I'm trying to create a web service client in Java. I've gotten this far:

String endpoint = "http://ajax.syr.edu/causp/kt/ktWebservice.asmx?wsdl";


Evan, you are using the Dynamic invocation API of Axis JAX-RPC: the Call interface.
This interface requires an endpoint that is actually a URL referenced in the location attribute of service, port, address element of the WSDL.
I do have the impression that the endpoint you are using is returning you the WSDL itself but is not the endpoint for your Soap service call.
You should try http://ajax.syr.edu/causp/kt/ktWebservice.asmx

You should also pay attention to compatibility issues for accessing .Net web services from Java. In particular specify a value for soapAction.

Robin
 
Evan McCarthy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

are u able to get any browser when you type http://ajax.syr.edu/causp/kt/ktWebservice.asmx?wsdl in browser ?



Yes. When I go there, I get the xml. If I go to http://ajax.syr.edu/causp/kt/ktWebservice.asmx (without the ?wsdl), I get an API description.
 
Evan McCarthy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

you should use some tool to geanerate webservice proxy class from WSDL file such as



I was using the ColdFusion webservice proxy generator in Dreamweaver, but I get problems whenever a need to pass an array as a argument. I'm guessing that coldFusion arrays and the webservice's notion of arrays don't match up exactly.

I'll have to look into these other tools. Thanks for the advice.
 
Evan McCarthy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You should try http://ajax.syr.edu/causp/kt/ktWebservice.asmx



I have tried that, but I get the same error.

You should also pay attention to compatibility issues for accessing .Net web services from Java. In particular specify a value for soapAction.



This is all very new to me...could you elaborate a little? Thanks!

Evan
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic