Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to build a Java web service that receive data via HTTP Post

Posted on 2006-03-20
8
Medium Priority
?
192 Views
Last Modified: 2012-06-27
As above. Thanks.

Regards,
Rachel
0
Comment
Question by:zuzzi2
  • 3
  • 2
6 Comments
 
LVL 30

Accepted Solution

by:
Mayank S earned 1000 total points
ID: 16244116
Hi Rachel, start with the tutorial: http://java.sun.com/webservices/docs/1.6/tutorial/doc/ 

- Mayank.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16244122
There are also some code samples here:

http://java.sun.com/developer/codesamples/webservices.html
0
 
LVL 3

Expert Comment

by:javaoptimizer
ID: 16244239
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
 
public class Example1_client {
 
  public static void main (String[] args)
       throws Exception {
 
    System.out.println("\n\nCalling the SOAP Server to say hello\n\n");      
    URL url = new URL (args[0]);
    String name = args[1];
 
    Call call = new Call (  );
    call.setTargetObjectURI("urn:Example1");
    call.setMethodName("sayHello");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC;);
    Vector params = new Vector (  );
    params.addElement (new Parameter("name", String.class, name, null));
    call.setParams (params);
 
    System.out.print("The SOAP Server says: ");
 
    Response resp = call.invoke(url, "");
 
    if (resp.generatedFault (  )) {
      Fault fault = resp.getFault (  );
      System.out.println ("\nOuch, the call failed: ");
      System.out.println ("  Fault Code   = " + fault.getFaultCode (  ));
      System.out.println ("  Fault String = " + fault.getFaultString (  ));
    } else {
      Parameter result = resp.getReturnValue (  );
      System.out.print(result.getValue (  ));
      System.out.println(  );
    }
  }
}

for a better understanding look at -> http://www.oreilly.com/catalog/progwebsoap/chapter/ch03.html#62464
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 30

Expert Comment

by:Mayank S
ID: 16244253
That's only the client :) the Q is about developing the web-service itself. The client could be developed in anything, be it Java or .NET for example.
0
 
LVL 8

Assisted Solution

by:Leo Eikelman
Leo Eikelman earned 1000 total points
ID: 16261924
well if you are going to use HTTP Post to send data to your web service I suggest building a document style web service (as oppose to an RPC style one)

A web service is basically a public interface with an manual to tell it how to run (the WSDL file)

you can start by looking here
http://java.sun.com/webservices/docs/1.6/tutorial/doc/

http://www.roseindia.net/javacertification/wsd-guide/wsdl_implementation.shtml

I recently completed a document style web service in BEA Weblogic and it is quite easy to create one, as Weblogic creates the WSDL file for you.  

If you are programming in Weblogic you can start by looking here:

http://edocs.bea.com/wls/docs81/webserv/index.html

Cheers
0
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16465495
that's fine with me

Leo
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question