• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

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

As above. Thanks.

Regards,
Rachel
0
zuzzi2
Asked:
zuzzi2
  • 3
  • 2
2 Solutions
 
Mayank SAssociate Director - Product EngineeringCommented:
Hi Rachel, start with the tutorial: http://java.sun.com/webservices/docs/1.6/tutorial/doc/ 

- Mayank.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
There are also some code samples here:

http://java.sun.com/developer/codesamples/webservices.html
0
 
javaoptimizerCommented:
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Mayank SAssociate Director - Product EngineeringCommented:
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
 
Leo EikelmanDirector, IT and Business DevelopmentCommented:
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
 
Leo EikelmanDirector, IT and Business DevelopmentCommented:
that's fine with me

Leo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now