Problem with SOAP Web Services [message #1743086] |
Mon, 12 September 2016 00:06 |
Giulio Savoca Messages: 1 Registered: September 2016 |
Junior Member |
|
|
Hi all!
That's my first post and i write here beacuase i have a problem with Eclipse.
I am new to develope Web Service with Java and i occured to an issues with Eclipse.
I have the following WSDL file of a web service "www.webservicex.net/globalweather.asmx?wsdl"
I have read a lot about creating Web Services from WSDL, so i followed a guide on Internet for Eclipse to create a Web Service Client from WSDL. i got a lot of error and i dont know why, beacause with NetBeans it works.
Here's the code:
import java.io.IOException;
import java.io.PrintWriter;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import NET.webserviceX.*;
import NET.webserviceX.www.*;
/**
* Servlet implementation class CitiesServletClient
*/
public class CitiesServletClient extends HttpServlet {
private static final long serialVersionUID = 1L;
private GlobalWeather service;
private String parametro = "Italy";
/**
* @see HttpServlet#HttpServlet()
*/
public CitiesServletClient() {
super();
// TODO Auto-generated constructor stub
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
//Process result
String listaCittà = getCitiesByCountry(request.getParameter("TextArea1"));
out.println("<p>" + listaCittà + " Prova</p>");
}
}
private String getCitiesByCountry(java.lang.String countryName) {
// Note that the injected javax.xml.ws.Service reference as well as port objects are not thread safe.
// If the calling of port operations may lead to race condition some synchronization is required.
NET.webserviceX.www.GlobalWeatherSoap port = service.getGlobalWeatherSoap();
return port.getCitiesByCountry(parametro);
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
Thank you all anticipately for helps!
|
|
|
Powered by
FUDForum. Page generated in 0.01993 seconds