import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * @author dan.ware */ public class DMWS_Simple_Servlet extends HttpServlet { /** * Processes requests for both HTTP GET and POST methods. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); // For more info on consuming Web Services; // http://netbeans.org/kb/docs/websvc/client.html // // Docmail Simple API (Test) WSDL // https://www.cfhdocmail.com/Test_SimpleAPI/DocMail.SimpleAPI.asmx?WSDL // // Docmail Test website // https://www.cfhdocmail.com/test/ // // This example uses the [SendLetterToAddressCSV_AllFromURLs] operation try { // Call Web Service Operation org.tempuri.QuickMail service = new org.tempuri.QuickMail(); org.tempuri.QuickMailSoap port = service.getQuickMailSoap(); // NOTE: The following code was automatically generated by NetBeans // initialize WS operation arguments here java.lang.String sUsr = "JavaTest"; java.lang.String sPwd = "javatest"; java.lang.String sMailingName = "JAVA TEST"; java.lang.String sCallingApplicationID = "DMWS_Simple_Servlet"; java.lang.String sTemplateURL = "https://www.cfhdocmail.com/Test_SimpleAPI/apitest.doc"; boolean bColour = false; boolean bDuplex = false; org.tempuri.DeliveryType eDeliveryType = org.tempuri.DeliveryType.FIRST_CLASS; org.tempuri.AddressNameFormat eAddressNameFormat = org.tempuri.AddressNameFormat.TITLE_FIRSTNAME_SURNAME; java.lang.String sAddressCSVURL = "https://www.cfhdocmail.com/Test_SimpleAPI/apitest1.csv"; java.lang.String sCSVFieldMappingName = ""; boolean bProofApprovalRequired = false; // process result here org.tempuri.Result oResult = port.sendLetterToAddressCSVAllFromURLs(sUsr, sPwd, sMailingName, sCallingApplicationID, sTemplateURL, bColour, bDuplex, eDeliveryType, eAddressNameFormat, sAddressCSVURL, sCSVFieldMappingName, bProofApprovalRequired); // display result information if (oResult.getErrorText().length() > 0) { out.println("

FAILED:
"+oResult.getErrorText()+"

"); } else { out.println("

Result:
"); out.println("Order "+oResult.getOrderNumber()+" created
"); out.println("Order value: £"+oResult.getCost()+" - "+oResult.getBalanceMessage()); out.println("

"); } out.println(""); out.println(""); out.close(); } catch (Exception ex) { System.out.println("Exception: "+ex); out.println("

Exception:
"+ex+"

"); } out.println(""); out.println(""); out.close(); } // /** * Handles the HTTP GET method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP POST method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. * @return a String containing servlet description */ @Override public String getServletInfo() { return "Short description"; }// }