FavoriteNagaraju Chigicherla (Daimler Truck Innovation Center) asked in #VisualforceAug 18, 2015, 9:41 AMHi I am getting errorThis is my page<apex:page sidebar="false"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Webservice tester</title> </head> <body> <form action="soaprequestservlet" method="post"> <label for="wsdl">Webservice endpoint</label> <input type="text" name="wsdl" size="120" id="wsdl" style="font-size: 11px; color: blue;"/> <input type="submit" name="Test SOAP Request" value="Test SOAP Request"/> <label for="FormatXML">Format XML</label> <input id="FormatXML" type="checkbox" name="formatXML" value="formatXML" checked="checked"/><br></br> <h3>SOAP Request</h3> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td width="45%"> <textarea style="font-size: 11px; color: blue;" name="soapmessage" cols="80" rows="40" title="SOAP MessageRequest" id="soaprequest"></textarea> </td> <td width="45%"> <h3>SOAP Response</h3> <textarea style="font-size: 11px; color: blue;" name="soapmessageresponse" cols="80" rows="40" title="Soap Request" id="soapresponse"></textarea> </td> </tr> </table> </form> </body> </html> </apex:page>Controllerpublic class SoapResponse { public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { //Whether to format the SOAP message response or not. String formatXML = request.getParameter("formatXML"); //Get the endpoint if (!request.getParameter("endpoint").equals("")) wsURL = request.getParameter("endpoint"); else throw new ServletException("Missing endpoint location!"); //Get the SOAP message request String xmlInput = request.getParameter("soapmessage"); requestMessage = xmlInput; //Code to make a webservice HTTP request URL url = new URL(wsURL); URLConnection connection = url.openConnection(); HttpURLConnection httpConn = (HttpURLConnection)connection; String responseString = ""; String outputString = ""; //Optional: set your action //String SOAPAction = // "http://litwinconsulting.com/webservices/GetWeather"; ByteArrayOutputStream bout = new ByteArrayOutputStream(); OutputStream out = null; InputStreamReader isr = null; BufferedReader in = null; byte[] buffer = new byte[xmlInput.length()]; buffer = xmlInput.getBytes(); bout.write(buffer); byte[] b = bout.toByteArray(); // Set the appropriate HTTP parameters. httpConn.setRequestProperty("Content-Length", String.valueOf(b.length)); httpConn.setRequestProperty("Content-Type", "text/xml; charset=utf-8"); //Optional: set your action //httpConn.setRequestProperty("SOAPAction", SOAPAction); httpConn.setRequestMethod("POST"); httpConn.setDoOutput(true); httpConn.setDoInput(true); out = httpConn.getOutputStream(); // write the content of the request to the outputstream of the HTTP Connection. out.write(b); out.close(); // ready with sending the request // Read the response. isr = new InputStreamReader(httpConn.getInputStream()); in = new BufferedReader(isr); //Write the SOAP message response to a String. while ((responseString = in.readLine()) != null) { outputString = outputString + responseString + (formatXML == null ? "\n" : ""); } //Format the message when the checkbox is checked. if (formatXML != null) outputString = format(outputString); //write the XHTML response. response.setContentType(CONTENT_TYPE); PrintWriter printWriter = response.getWriter(); printWriter.println("<?xml version=\"1.0\"?>"); printWriter.println(DOC_TYPE); printWriter.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"); printWriter.println("<head><title>Webservice tester</title></head>"); printWriter.println("<body>"); printWriter.println("<form action=\"soaprequestservlet\" method=\"post\">"); printWriter.println("<label for=\"wsdl\">Webservice endpoint</label>"); printWriter.println("<input type=\"text\" name=\"endpoint\" value=\"" + wsURL + "\" size=\"120\" id=\"wsdl\" style= \"; font-size: 12px; color: blue;\" />"); printWriter.println("<label for=\"FormatXML\">Format XML</label>"); printWriter.println("<input id=\"FormatXML\" type=\"checkbox\" name=\"formatXML\" value=\"formatXML\" checked=\"checked\"/>"); printWriter.println("<p/><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"); printWriter.println("<tr>"); printWriter.println("<td width=\"45%\">"); printWriter.println("<h3>SOAP Message Request</h3>"); printWriter.println("<textarea style= \"; font-size: 11px; color: blue\"; name=\"soapmessage\" cols=\"80\" rows=\"40\" title=\"SOAP Message Request\" id=\"soaprequest\">" + requestMessage + "</textarea>"); printWriter.println("</td>"); printWriter.println("<td width=\"45%\">"); printWriter.println("<h3>SOAP Message Response</h3>"); printWriter.println("<textarea style= \"; font-size: 11px; color: blue\"; name=\"soapmessageresponse\" cols=\"80\" rows=\"40\""); printWriter.println("title=\"SOAP Message Response\" id=\"soapresponse\""); //write the SOAP message response to the textarea. printWriter.println(outputString); //Continue writing XHTML printWriter.println("</textarea>"); printWriter.println("</td>"); printWriter.println("</tr>"); printWriter.println("</table>"); printWriter.println("<input type=\"submit\" name=\"Test SOAP Request\" value=\"Test SOAP Request\"/>"); printWriter.println("</form>"); printWriter.println("</body></html>"); printWriter.close(); }}Hi I am getting This error [Error] Error: SoapResponse Compile Error: unexpected token: 'throws' at line 3 column 80.The Above code developed in java so this entire code convert to salesforce how can i convert this entire code plz anyone give me solution .plz its urgent for me.ThanksRajShow More1 answerSortSort by DateSort by Most HelpfulSort by DateNagaraju Chigicherla (Daimler Truck Innovation Center)Aug 20, 2015, 7:47 AMHi Plz anyone give ideas RajAdd a commentWrite an answer...BoldItalicUnderlineStrikethroughBulleted ListNumbered ListAdd linkCode blockInsert imageAttach filesLink URLCancelSave0/9000Reply
Nagaraju Chigicherla (Daimler Truck Innovation Center)Aug 20, 2015, 7:47 AMHi Plz anyone give ideas Raj