Calling a SOAP web service from Java client

Поделиться
HTML-код
  • Опубликовано: 5 янв 2025

Комментарии • 96

  • @taylorrembos9790
    @taylorrembos9790 3 года назад +5

    This is a fantastic walkthrough. Efficient, to the point, but you still explained what every line is doing. You really furthered my understanding here - thank you for being a great teacher

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  3 года назад +1

      Glad you enjoyed it!

    • @vijayendranvijay4538
      @vijayendranvijay4538 Год назад

      @@SoftwarepulseCoUk Great video... I am consuming soap webservice using rest assured.. Its a get() method.. I get the success response code 200 but the response message is coming as text/html instead of text/xml though I have explicitly set the headers as text/xml in headers... Could u pls help?

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  Год назад

      Hi @@vijayendranvijay4538, thanks for your question. Do you know if the web service you are calling supports XML? Try SoapUI or another such tool to call the web service and see what format it returns. My video is about calling Soap Web Services which uses XML by default. REST web services tend, these days, to return JSON although they can use other formats. Hope this helps.

  • @ricardoespindola8293
    @ricardoespindola8293 4 года назад +4

    John, you have saved my life!!! I´ve been searching for something simple and direct when using wsdl in Java for a long time. Just found complex code and "not so good" results... Thanks man!!!

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад +1

      Hi Ricardo, Glad I could help and good luck with your project.
      Regards John

  • @crtdian5284
    @crtdian5284 2 года назад

    Had to switch to my phone to be on my youtube account to THANK YOU !
    What a simple way to do it, as a beginner I had no Idea SoapUI actually existed, and for the main part on Java, finally something simple and fonctionnal.
    Very helpful, I've been stuck for one week on that and now I can move on.

  • @edivaldonogueira8683
    @edivaldonogueira8683 4 года назад

    Congratulations John, first code that really works, no mess.

  • @giulianocarmona7250
    @giulianocarmona7250 4 года назад

    awesome man, I just glanced at your others videos and there is a bunch ones that will help me a lot.
    I'm trying to be as good as you, and one day I will, especially with your help.
    Keep on track, you're helping us more than you can imagine

  • @davidkrivan4704
    @davidkrivan4704 4 года назад +1

    King of kings. I have been looking for so long and now I found it the best solution for my work, thank you man.

  • @amanpainuly6796
    @amanpainuly6796 4 года назад

    Hi John, Many thanks for creating this amazing tutorial and simplifying all the complexities for a beginner in SOAP ws. My Best wishes to you and your channel.

  • @emmaprofemx
    @emmaprofemx 10 месяцев назад

    Wooow amazing video , excellent explanation...new sub.Congratulations John

  • @bhaskarverma9810
    @bhaskarverma9810 3 года назад +1

    Nice video .How to create xml input request from wsdl. I am unable to create it. Can you please guide on this.

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  3 года назад

      Hi Bhaskar,
      if you are trying to work with a web service that you did not build then you can see if they have published the wsdl as part of the service by adding ?wsdl to the end of the service uri. Take a look at my playlist 'The naked web service' and specifically 'Deploying and Testing the Web Service' for an example of accessing the wsdl. I then use the application SoapUI to create a request from the wsdl, also see the video. That is a simple way to get going.
      Hope that helps.
      Regards,
      John

  • @jgoungs
    @jgoungs 11 дней назад

    Please can I use this for Rest webservice as well?

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  7 дней назад

      Yes, you can use this approach to call a REST web service.

  • @nagarajujallipalli9798
    @nagarajujallipalli9798 3 года назад

    John, thanks for this video . We need to modify the xml tag values and sent to UI . Can you please let me know how can achieve it.

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  3 года назад

      Hi Nagaraju, not sure what you are asking. The actual xml is determined by the web service. You can send any part of the response to the UI that you want. Can you provide more information?

  • @cuaugarza6649
    @cuaugarza6649 2 года назад

    Thank you very much. I saved my job with your video

  • @kooroshnavi677
    @kooroshnavi677 Год назад

    Saved my life. Thank You.

  • @akshaykirankv4171
    @akshaykirankv4171 3 года назад

    ow to invoke web services on WSDL URL and consume data from it in Java?

    • @akshaykirankv4171
      @akshaykirankv4171 3 года назад

      How to invoke web services on WSDL URL and consume data from it in Java?

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  3 года назад

      Hi, not sure about what you are asking but I think it is to do with using the WSDL to call a web service. take a look at the play list on building a web service which creates and uses a WSDL and this might help. ruclips.net/video/liGI_8GSdWA/видео.html

  • @angry_fox
    @angry_fox 2 года назад

    Thank you! Your tutorial very helpful for me. But If in the sayHelloResponce I will have two tags, for example and . How I can get only 0ne value?

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  2 года назад

      Hi Tatyana, I think you are asking if you have a web service that returns more then one value how can you select a specific value from the XML returned? First off, I would point you at the play list I put together of building a complete basic SOAP web service and then consume it using Java. This ruclips.net/p/PL-kphvZHYe7JIA11I55nbkK9eB76XGhr- may help. If you return more than 1 item, each will have its own tag so, you would navigate the document to locate the item and then extract the value. Hope this helps.

    • @angry_fox
      @angry_fox 2 года назад +1

      @@SoftwarepulseCoUk thank you for help! it work)

  • @vinodkumar-iv4kr
    @vinodkumar-iv4kr 2 года назад

    This video helped me in achieving in consuming web services but when I pass the arguments I am not able to get the response back. If I pass the variable hard coded I am getting response.any thoughts when we pass variables dynamically it is not giving response back

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  2 года назад

      Hi Vinod, you didn't provide an example of what you tried. If I was going to use the arguments passed to the method then I would change these lines
      "George" +
      "44" +
      to this
      "" + name + "" +
      "" + age + "" +
      Hope this helps.

    • @vinodkumar-iv4kr
      @vinodkumar-iv4kr 2 года назад

      @@SoftwarepulseCoUk thanks John for replying. Here is the example I am using For my reference +" + locn + "
      +"+ employeeId + "
      +"+ upcList + "

    • @vinodkumar-iv4kr
      @vinodkumar-iv4kr 2 года назад

      @sofware pulse John I am able to resolve the issue in my case I had the argument long the zero was not appending in my case.

    • @johnmcneil1009
      @johnmcneil1009 2 года назад +1

      @@vinodkumar-iv4kr, thanks for providing your example. Assuming the employeeId and upcList are your variables then you are missing some double quotes. It should look like this:
      +"" + employeeId + ""
      +"" + upcList + ""
      You need open and close double quotes around "" and then the same with the closing tag "". Hope that helps. Happy coding!

  • @israaodeh99
    @israaodeh99 3 года назад

    Just Amazing man! Big thanks!!

  • @novaoli1625
    @novaoli1625 4 года назад

    Cannot process the message because the content type 'text/plain;charset=ISO-8859-1' was not the expected type 'text/xml; charset=utf-8'.: [no body]
    i am getting this error, what should i do

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад

      Hi, Without more information about what you are doing its difficult to know. It looks like you are calling a web service using one character set when it is expecting another. Have you tried changing the character set you are using in your call?

    • @novaoli1625
      @novaoli1625 4 года назад

      @@SoftwarepulseCoUk I am trying to call a soap web service and I am sending the XML request using the rest template, in content type I am sending text/XML but this is the error I am getting. I consumed other soap service in same way but I am able to consume it.

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад

      OK first off I see you are using a REST template. This example is a SOAP-based example so you might need to look at a REST example to help overcome your problem. I also see in the error message the term ''text/plain;charset=ISO-8859-1' and in your response you state you are sending text/XML. This is clearly a mismatch and maybe the issue. Finally, I see you have successfully called other SOAP services. That is good as you have a working example, however, you are now trying to call a REST service so you may need to change things. I have never yet had to consume a Restful service so can't provide much insight there. Good luck in finding a solution.

  •  4 года назад

    Hi John I have an XML soap request with must understand attribute.how can i code it in java???

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад

      Hi Ayudh, will need a little more information to be able to offer any suggestions. Are you calling an existing web service? What information do you have about the web service? What have you done so far?

  • @vinayakmahadev488
    @vinayakmahadev488 4 года назад

    Is possible to send and receive multiple txt file from soap service... if possible means share me consumer code as like ur video

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад

      Hi Vinayak, Yes it is possible to send files to and from a soap service. I do not have anything in a format to share but don't let that stop you from building your own. There is plenty of information out there and many people willing to help you if you get stuck. Have a go and good luck.

  • @fernandohood5542
    @fernandohood5542 4 года назад

    I just started watching your video and u lost me at the start on checking to see if the service is running. How do we do that?

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад

      Hi Fernando, this video is part of a series of videos. If you look at the description below the video there are links to blog articles that cover building the web service and building a java client to call the web service. Alternatively, you could look at the RUclips playlist ruclips.net/p/PL-kphvZHYe7JIA11I55nbkK9eB76XGhr- which takes you through each step of building the web service and then calling it.
      Hope this helps
      Regards,
      John

  • @CrisHendricks
    @CrisHendricks 4 года назад

    Thanks so much for this video! Do you have any advice if I want to add a certificate to my request? Thanks again!

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад +1

      Hi Cris, sorry this is not something I have been involved with or have any experience with. I wish you all the best in your endeavours.

  • @gilbertrosales967
    @gilbertrosales967 10 дней назад

    works, good video!

  • @gus0bigolin
    @gus0bigolin 2 года назад

    Thank you so much for your work! It has been a lifesaver! Keep it up! Please! lol

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  2 года назад

      You're welcome! I'm glad I was able to help. Good luck with your learning journey.
      Regards,
      John

  • @sarveshshrivastavg
    @sarveshshrivastavg 4 года назад

    How can we add Basic Authorization to this code?

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад

      Hi, You can add basic authentication to your call with just a couple of lines. Of course, the service you are calling will need to support authentication as well.
      httpConn.setRequestProperty("SOAPAction", SOAPAction);
      httpConn.setRequestMethod("POST");
      httpConn.setDoOutput(true);
      httpConn.setDoInput(true);
      String encoding = Base64.getEncoder().encodeToString(("userid:password").getBytes("UTF‌​-8"));
      httpConn.setRequestProperty ("Authorization", "Basic " + encoding);
      out = httpConn.getOutputStream();
      out.write(buffer);
      out.close();
      So, from the code above the new lines are the "String encoding" and the "setRequestProperty" method call.
      Hope this helps.
      Regards,
      John

  • @GodwinThaya
    @GodwinThaya 4 года назад

    Thanks John from India

  • @NikksVipul
    @NikksVipul 2 года назад

    Hi, Great Explanation. Can we please access to the code that you showed here.

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  2 года назад +1

      Hi Vipul, I have added the source code to GitLab which you can find here. gitlab.com/johnmc-sp/calling-soap-web-service-from-java. Hope this helps.

  • @azlinmuhamadali
    @azlinmuhamadali 3 года назад

    Thanks bro, simple but functioning...nice

  • @avrajitghosh5614
    @avrajitghosh5614 2 года назад

    Not working. Getting 403 error.

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  2 года назад

      An HTTP 403 error is usual when you try and access a resource that you do not have permission for.
      You have not provided any details about what you have done so it is difficult to say what the issue may be.
      Did you test calling the web service from a tool such as SOAPUI or Postman first?

  • @sarveshshrivastavg
    @sarveshshrivastavg 4 года назад

    Please share the source code of this example.

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад

      The source code for this can be found on my web site - softwarepulse.co.uk/blog/java-client-calling-soap-web-service/

  • @kevina4826
    @kevina4826 2 года назад

    It Works, thank you so much

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  2 года назад

      Hi Kevin, glad it worked and hope it helps you with whatever you are working on.

  • @wasj8336
    @wasj8336 2 года назад

    Muchas gracias !!!. Sencillo, practico y didáctico.

  • @Open-Media
    @Open-Media 4 года назад

    what jars are required for this ?

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад

      Hi Badri, You need log4j-api-2.10.0.jar and log4j-core-2.10.0. Earlier versions will work as I started with 2.8.2. Make sure you are using a version starting with '2' as those starting with '1' are version one and uses different commands and configuration options.
      Regards,
      John

  • @kolob204
    @kolob204 3 года назад

    Got 500 server error, but in soapui request worked

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  3 года назад

      Restart the web server and see if you still get the problem. Also check the the URL you are using in SOAP and Java are actually the same, sometimes it is easy to make a mistake.

  • @javadev8682
    @javadev8682 3 года назад

    Thanks Jhon, for me it is very help full.

  • @_fluid__591
    @_fluid__591 3 года назад

    will the same work over HTTPS?

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  3 года назад

      Hi Mukesh, good question. No, you will need to use HttpsURLConnection for a start. Not really looked at this so can't comment any more than that.

    • @crtdian5284
      @crtdian5284 2 года назад

      Worked for me, had to add the webservice certificate to my JDK (in lib/security/cacerts with command line easy to google)

  • @samjuthecoder2310
    @samjuthecoder2310 2 года назад

    Great tutorial.

  • @karimsettisandeep3135
    @karimsettisandeep3135 3 года назад

    This tutorial helped me achieve what I have exactly intended to do. Thank you @Software Pulse. Your explanation is razor sharp!! But I am facing a difficulty, can pls try to address it. I have created a similar method that you have coded in the main method and it works great in a standalone java client program but when I have created a similar method and placed inside a Java web client program, the web server moves to next line of code before the web service call completes and response is returned by the method. There by a variable ends up with a null value instead of storing the string response returned by the method call. I am expecting the webserver to wait until the response is returned by the web service and then to move forward.

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  3 года назад

      Hi Karimsetti, I think I would need to see your code in order to offer any help.

    • @karimsettisandeep3135
      @karimsettisandeep3135 3 года назад

      @@SoftwarepulseCoUk Thank you for replying back. Initially I was using HttpURLConnection class to invoke the web service from Java client code and ran into tho above mentioned issue. Later I was able to get rid of it when I had changed my client code to use SOAPConnection class.

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  3 года назад

      @@karimsettisandeep3135 Glad to see you found a solution to your problem. Yes, SOAPConnection seems to be a simpler way of interacting with the SOAP web service so well done in working that out. Your issue raises an interesting question. I wonder if the HttpURLConnection was timing out? You can set the amount of time a getInputStream() will wait before timing out with setReadTimeout(). Just a thought.
      Anyway, good luck with your coding journey.

    • @karimsettisandeep3135
      @karimsettisandeep3135 3 года назад

      @@SoftwarepulseCoUk Sure, I'll check this too, might be helpful in future. Thanks for your replies and suggestions. I'll be glad if you can drop a test email to me (sandeepkarimsetti@gmail.com) to stay in touch. 😊

  • @chueher9828
    @chueher9828 3 года назад

    Thank you sooo much!

  • @matejamarinkovic4063
    @matejamarinkovic4063 4 года назад

    Hi, do you have email where i can contact you ?

    • @SoftwarepulseCoUk
      @SoftwarepulseCoUk  4 года назад

      Hi Mateja, of course. Take a look at the About section for my website at softwarepulse.co.uk.

  • @felipe_bento
    @felipe_bento 4 года назад

    Very good!!

  • @alexandermaldonado6104
    @alexandermaldonado6104 2 года назад

    Excelent!!!!!

  • @shravanustad
    @shravanustad 3 года назад

    Thankyou so much...