저는 webservice에서 새롭습니다. 400 xml을 webservice에 전달할 때 잘못된 요청이 있습니다.
나는,이같은 오류가 발생했습니다 내가 코드를 실행하면 내 코드
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>"; System.out.println(xmldata); 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(); }
가 여기
plog.asmx라는 영문 웹 서비스에 XML을 통과 한 HTTP/1.1 400 잘못된 요청 캐시 제어 : 개인 콘텐츠 형식 : 텍스트/xml; 0xX-AspNet-Version : 4.0.30319 X-Powered-By : ASP.NET 날짜 : 2012 년 12 월 13 일 목요일 09:37:12 GMT Content- 길이 : 0
나는 오류를 봤하고 해결하기 위해 노력하지만 해결책은
JAX-WS를 사용하고 싶지 않습니다. 다른 해결책이 있습니까? @fredcrs .. i – Raymond
해결책이 없으면 웹 서비스를 다른 프로젝트로 어떻게 내보낼 수 있습니까? – Raymond
theres 여기에 좋은 대답 http://stackoverflow.com/questions/3463216/java-simple-soap-client – fredcrs