Results 1 to 2 of 2
  1. #1
    Doyle Raymond is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default Pass xml to web service

    Hello Everyone,

    I'm new in webservice.

    I've to pass xml to aspx web service called plog.asmx



    here is my code

    Java Code:
    String xmldata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + 
    		        "<SOAP:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + 
    		          "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + 
    		          "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" >" +
    		          "<![CD[<soap:Body>" +
    		          "<SubmitJob xmlns=\"http://www.xdel.biz/XWS/\"> " +
    		          "<APIKey>"+ API_KEY +"</APIKey>" +
    		          "<Job>" +
    		           "<Customer_Name>"+ Customer_Name +"</Customer_Name>" +
    		           "<Address1>"+ Address1 +"</Address1>" +
    		            "<Address2>"+ Address2 +"</Address2>" +
    		            "<Postal_Code>"+ Postal_Code +"</Postal_Code>" +
    		            "<Phone_Number>"+ Phone_Number +"</Phone_Number>" +
    		            "<Mobile_Number>"+ Mobile_Number +"</Mobile_Number>" +
    		            "<Order_Reference>"+ Order_Reference +"</Order_Reference>" +
    		            "<Delivery_Instructions>"+ Delivery_Instructions +"</Delivery_Instructions>" +
    		          "</Job>]]>" +
    		        "</SubmitJob>" +
    		          "</soap:Body>]]>" +
    		          "</SOAP:Envelope>";
    		
    				  try{
    			          //Create socket
    			          String hostname = "www.xdel.biz";
    			          int port = 80;
    			          InetAddress  addr = InetAddress.getByName(hostname);			          
    			          Socket sock = new Socket(addr, port);
    			          System.out.println(sock.toString());			          
    			          
    			          //Send header
    			          String path = "/xws/plog.asmx";
    			          BufferedWriter  wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(),"UTF-8"));
    			          // You can use "UTF8" for compatibility with the Microsoft virtual machine.
    			          wr.write("POST " + path + " HTTP/1.1\r\n");
    			          wr.write("Host: www.xdel.biz\r\n");
    			          wr.write("Content-Type: text/xml; charset=utf-8\r\n");
    			          wr.write("Content-Length: " + xmldata.length() + "\r\n");			          
    			          wr.write("SOAPAction: \"http://www.xdel.biz/XWS/SubmitJob\" \r\n");
    			          wr.write("\r\n");
    			          	
    			          //Send data
    			          wr.write(xmldata);
    			          wr.flush();
    
    			          System.out.println("1");
    			          
    			          // Response
    			          BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream()));
    			          String line;
    			          while((line = rd.readLine()) != null){
    			        	  System.out.println(line);
    			          }
    			          
    			        } catch (Exception e) {
    			          e.printStackTrace();
    			        }
    when I run the code, I got error like this


    Java Code:
    HTTP/1.1 400 Bad Request
    Cache-Control: private
    Content-Type: text/xml; charset=utf-8
    Server: Microsoft-IIS/7.5
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    Date: Thu, 13 Dec 2012 09:37:12 GMT
    Content-Length: 0

    I googled the error and tried to fix but no solution come out..


    I'm kind of urgent and it's needed for my project.

    Thanks in advance

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: Pass xml to web service

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. please help. we need to pass this tom.
    By rochellelising in forum New To Java
    Replies: 1
    Last Post: 08-24-2011, 11:17 AM
  2. how to pass parameter from one jsp to another jsp
    By kader_sit in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-10-2010, 02:04 PM
  3. Pass String Value
    By DJCali in forum New To Java
    Replies: 2
    Last Post: 03-03-2010, 12:48 AM
  4. how to pass data
    By rakesh_mca in forum Java Servlet
    Replies: 7
    Last Post: 10-25-2009, 01:13 PM
  5. how to call service method inside another service
    By kirtichopra2003 in forum Web Frameworks
    Replies: 1
    Last Post: 10-24-2009, 02:19 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •