This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes Webservices - communication exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Webservices - communication exception" Watch "Webservices - communication exception" New topic
Author

Webservices - communication exception

sriram varadharajan
Greenhorn

Joined: Jan 03, 2007
Posts: 9
I am reading the book SOA using JWS by Mark Hansen and trying out the examples . i am stuck with the example that teaches how to post xml to a REST based webservice without using JAX-WS.

Using maven i have deployed the webservice and i am trying to post an XML file to it using the client.
This is the client code that is trying to connect to service . it is basic HTTP connection and does not involve the JAX-WS API

public class PostCustomerHistory {

//! <example xn="PostCustomerHistory_Client_HTTP">
//! <c>chap03</c>rest-post
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println
("Usage: java PostCustomerHistory <XML file name> "
+ "<Web Service URL>");
System.exit(1);
}
FileInputStream in = new FileInputStream(args[0]);
URL url = new URL(args[1]);
HttpURLConnection con =
(HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setRequestMethod("POST");
System.out.println("Before connectionggggggg"+args[1]);
con.connect();

OutputStream out = con.getOutputStream();

// write the XML doc from file to the HTTP connection
byte[] b = new byte[1024]; // 1K buffer
int result = in.read(b);
while (result != -1) {
out.write(b,0,result);
result = in.read(b);
}
System.out.println("After connectionggggggg");
out.close();
in.close();
// write HTTP response to console
System.out.println(con.getResponseCode() +
" srirammmmmmmmmmmmmmm" + con.getResponseMessage());
}
//! </example>
}

the exception i get is

run-servlet:
[java] Before connectionggggggghttp://localhost:8080/chap03-restpost-endpoi
nt-servlet-1.0/CustomerHistory?SourceSystem=OMS
[java] After connectionggggggg
[java] 500 srirammmmmmmmmmmmmmmThe system cannot find the path specified
[INFO] Executed tasks
[INFO] [install:install {execution: default-install}]
[INFO] Installing C:\webservicesCodeSamples\chap03\rest-post\client-http\target\
chap03-restpost-client-http-1.0.jar to C:\Documents and Settings\svaradharajan\.
m2\repository\soabook\chap03-restpost-client-http\1.0\chap03-restpost-client-htt
p-1.0.jar


please let me know where i am going wrong.Both the client and server are in the same machine.


thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Webservices - communication exception