Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Web Services
Search Coderanch
Advance search
Google search
Register / Login
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
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Web Services
My first webservice call
Shriram Krishnamoorthy
Greenhorn
Posts: 5
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello All,
I am trying to write a webservice call client for a webservice at
http://www.webservicex.net/WeatherForecast.asmx?WSDL
. But I have some problms in invokint the call. This is the code I have. Please let me know whats wrong with it.
import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.XMLType; import org.apache.axis.utils.Options; import javax.xml.rpc.ParameterMode; public class WebClient{ public static void main(String [] args) throws Exception { Options options = new Options(args); String endpoint = "http://www.webservicex.net"; // Do argument checking args = options.getRemainingArgs(); System.out.println(args); if (args == null || args.length != 1) { System.err.println("Usage: Zipcode number value needs to be entered"); return; } // Make the call String i1 = new String(args[0]); Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName("GetWeatherByZipCode"); call.addParameter("ZipCode", XMLType.XSD_STRING, ParameterMode.IN ); //call.setReturnType(XMLType.XSD_STRING); Object ret = (Object) call.invoke( new Object [] { i1 }); //Object obj=call.invoke(args); //System.out.println("Got result : " + ret); } }
Ulf Dittmer
Rancher
Posts: 43081
77
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
But I have some problms in invokint the call.
What problems are those?
TellTheDetails
Also, please edit your post to
UseCodeTags
. It's unnecessarily hard to read the code as it is, making it less likely that people will bother to do so.
Shriram Krishnamoorthy
Greenhorn
Posts: 5
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is the error message after invoking the service
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle). log4j:WARN Please initialize the log4j system properly. org.apache.axis.client.Call@cec0c5 Exception in thread "main" AxisFault faultCode: {http://xml.apache.org/axis/}HTTP faultSubcode: faultString: (405)Method Not Allowed faultActor: faultNode: faultDetail: {}:return code: 405 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> ; <HTML><HEAD><TITLE>The page cannot be displayed</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252"> <STYLE type="text/css"> BODY { font: 8pt/12pt verdana } H1 { font: 13pt/15pt verdana } H2 { font: 8pt/12pt verdana } A:link { color: red } A:visited { color: maroon } </STYLE> </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD> <h1>The page cannot be displayed</h1> The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access. <hr> <p>Please try the following:</p> <ul> <li>Contact the Web site administrator if you believe that this request should be allowed.</li> <li>Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly. </li> </ul> <h2>HTTP Error 405 - The HTTP verb used to access this page is not allowed.<br>Internet Information Ser vices (IIS)</h2> <hr> <p>Technical Information (for support personnel)</p> <ul> <li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support Ser vices</a> and perform a title search for the words <b>HTTP</b> and <b>405</b>.</li > <li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr), and search for topics titled <b>Setting Application Mappings</b>, <b>Securing Your Site with Web Site Permissions</b>, and <b>About Custom Error Messages</b>.</li> </ul> </TD></TR></TABLE></BODY></HTML> {http://xml.apache.org/axis/}HttpErrorCode:405 (405)Method Not Allowed at org.apache.axis.transport.http.CommonsHTTPSender.invoke(CommonsHTTPSender.java:219) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2784) at org.apache.axis.client.Call.invoke(Call.java:2767) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812) at WebClient.main(WebClient.java:40)
Ulf Dittmer
Rancher
Posts: 43081
77
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You may want to use a tool like tcpmon or SOAPUI to monitor what's going over the wire. The default HTTP method for
SOAP
is POST, so if the service doesn't like what's being sent
you should
examine what *is* being sent.
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Accessing .NET web service from java
Error in client for webservice on websphere 4.0
consume web service
Soap client giving error
Use Web Service
More...