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 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?
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.
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!!!
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.
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
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.
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
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?
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
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.
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
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, 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!
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
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?
@@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.
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???
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?
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.
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
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
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?
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
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.
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 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.
@@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.
@@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. 😊
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
Glad you enjoyed it!
@@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?
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.
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!!!
Hi Ricardo, Glad I could help and good luck with your project.
Regards John
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.
Glad this helped and good luck with your project.
Congratulations John, first code that really works, no mess.
Thanks 👍
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
Glad to help
King of kings. I have been looking for so long and now I found it the best solution for my work, thank you man.
You're very welcome!
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.
Glad it was helpful!
Wooow amazing video , excellent explanation...new sub.Congratulations John
Thanks glad you enjoyed it.
Nice video .How to create xml input request from wsdl. I am unable to create it. Can you please guide on this.
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
Please can I use this for Rest webservice as well?
Yes, you can use this approach to call a REST web service.
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.
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?
Thank you very much. I saved my job with your video
I'm glad you found it useful.
Saved my life. Thank You.
ow to invoke web services on WSDL URL and consume data from it in Java?
How to invoke web services on WSDL URL and consume data from it in Java?
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
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?
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.
@@SoftwarepulseCoUk thank you for help! it work)
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
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.
@@SoftwarepulseCoUk thanks John for replying. Here is the example I am using For my reference +" + locn + "
+"+ employeeId + "
+"+ upcList + "
@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.
@@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!
Just Amazing man! Big thanks!!
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
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?
@@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.
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.
Hi John I have an XML soap request with must understand attribute.how can i code it in java???
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?
Is possible to send and receive multiple txt file from soap service... if possible means share me consumer code as like ur video
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.
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?
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
Thanks so much for this video! Do you have any advice if I want to add a certificate to my request? Thanks again!
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.
works, good video!
Glad you got it to work and enjoyed the video.
Thank you so much for your work! It has been a lifesaver! Keep it up! Please! lol
You're welcome! I'm glad I was able to help. Good luck with your learning journey.
Regards,
John
How can we add Basic Authorization to this code?
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
Thanks John from India
Hi, Great Explanation. Can we please access to the code that you showed here.
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.
Thanks bro, simple but functioning...nice
Your welcome
Not working. Getting 403 error.
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?
Please share the source code of this example.
The source code for this can be found on my web site - softwarepulse.co.uk/blog/java-client-calling-soap-web-service/
It Works, thank you so much
Hi Kevin, glad it worked and hope it helps you with whatever you are working on.
Muchas gracias !!!. Sencillo, practico y didáctico.
You're welcome, glad you enjoyed it.
what jars are required for this ?
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
Got 500 server error, but in soapui request worked
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.
Thanks Jhon, for me it is very help full.
Glad you found it helpful.
will the same work over HTTPS?
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.
Worked for me, had to add the webservice certificate to my JDK (in lib/security/cacerts with command line easy to google)
Great tutorial.
Glad you liked it.
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.
Hi Karimsetti, I think I would need to see your code in order to offer any help.
@@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.
@@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.
@@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. 😊
Thank you sooo much!
Hi, do you have email where i can contact you ?
Hi Mateja, of course. Take a look at the About section for my website at softwarepulse.co.uk.
Very good!!
Thank you! Cheers!
Excelent!!!!!
Hi Alexander, glad you like it.
Thankyou so much...
You're welcome