Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Simple Java SOAP client

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple Java SOAP client

    Hi Everyone.

    I'm just starting out with Java (been a C/C++/Perl/PHP/Ruby programmer for many years).

    I'm really enjoying the language and everything has been quite plain sailing and straightforward - until now! Basically, I just want to write a very simple SOAP client in Java. I don't want it tied to any particular service, it's really a test-stub type application. To give you an idea of what I'm after (it really is something quick and dirty), here is something I knocked up in PHP:

    #!/usr/local/bin/php
    <?
    $client = new SoapClient("https://SOME_URL?WSDL", array);
    $params = array();
     
    // set parameters for method call
    $params['id'] = '12345';    // key for the update
    $params['no_of_widgets'] = "10";  // value for the "update" method
     
    $res = $client->__soapCall("update", array($params));  // call "update" with the params
     
    echo $client->__getLastRequest();
    echo "\n\n";
    echo $client->__getLastResponse();
     
    ?>

    I've google'd for simple SOAP clients in Java but many of them didn't work in my environment (J6SE, Netbeans, Linux 64 bit) - a lot of the time it was the "import"s at the top which were not found and therefore the code below had unknown classes etc. I've made sure the relevant libraries were installed (JAX, AXIS etc) and included in the NetBeans project but no luck. I also noticed the amount of code seemed to be very large but the demos were probably trying to achieve a lot more than I was.

    Can anyone help me translate the above PHP into Java or give any tips?

    Thanks
    Andy


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Simple Java SOAP client

    Hello there,

    Have a look at The Java(TM) Web Services Tutorial

    There are some simple enough tutorials out there to get you started with web services and SOAP. You might need to download the Web Services Development Pack as well if you havent already. It can be found at Java Web Services Downloads - Previous Releases

    // Json

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Re: Simple Java SOAP client

    Sorry to hijack this thread, but it ranks high on Google and it describes exactly my problem too. I too come from the world of other languages, like Java as a language, and I'm trying to connect to SOAP server to fetch some data.

    The Web Services Tutorial is way too big and it doesn't help with writing a simple SOAP client, as it was outlined by andy.

    Is Apache Ajax2 library the way to go? Or is there a part of a standard J6SE that would allow me to connect to some SOAP server?

    EDIT: forgot to mention - I have the WSDL.

    Thanks in advance,

    Andrew
    Last edited by andrew421; December 8th, 2010 at 08:27 AM.

  4. #4
    Junior Member
    Join Date
    Sep 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Re: Simple Java SOAP client

    bump? it seems like there is no such thing in the "almighty powerful Java" ??

    I'm having just the same problem, just need to call a web service and pass the xml string, that's all, but it's a real pain to do something as simple as that.

    or maybe there is a way but it's not documented ?? prove me wrong please

Similar Threads

  1. How to Write a simple XMPP (Jabber) client using the Smack API
    By JavaPF in forum Java Networking Tutorials
    Replies: 35
    Last Post: August 5th, 2014, 12:59 AM
  2. Replies: 0
    Last Post: December 12th, 2009, 10:09 PM
  3. Replies: 2
    Last Post: November 19th, 2009, 11:55 PM
  4. Simple server-client trouble
    By DC200 in forum Java Networking
    Replies: 3
    Last Post: November 12th, 2009, 08:16 AM
  5. SOAP Message Factory response error
    By Buglish in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: November 6th, 2008, 01:42 PM