2012-12-13 2 views
0

저는 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

나는 오류를 봤하고 해결하기 위해 노력하지만 해결책은

답변

0

좋은 ideia는 SOAP의 웹 서비스를 구현하고 이미 테스트 된 API를 사용하는 것입니다 .. 나오지 않습니다.

은 당신이 이미 가지고 without ![CD[ ]] block

+0

JAX-WS를 사용하고 싶지 않습니다. 다른 해결책이 있습니까? @fredcrs .. i – Raymond

+0

해결책이 없으면 웹 서비스를 다른 프로젝트로 어떻게 내보낼 수 있습니까? – Raymond

+0

theres 여기에 좋은 대답 http://stackoverflow.com/questions/3463216/java-simple-soap-client – fredcrs

0

프로토콜 (SOAP 또는 HTTP를) 불일치 할 때이 JAX-WS

400 잘못된 요청 가끔 일어나는 사용 "웹 서비스를 소모합니다. 문제는 거의 하루 만에 답을 찾은 후 소비 된 SOAP 메시지의 크기 인 XML의 크기라는 것을 알게되었습니다. 문제는 웹 서비스를 제공하는 애플리케이션이 커다란 XML 데이터를 수신하도록 설정되어야한다는 것입니다. 애플리케이션 서버를 확장하여 클라이언트에서 SOAP 메시지를받는 데 사용되는 버퍼의 크기를 늘려야했습니다. .

그건 우리 만료일이었습니다. 희망이 조금 있습니다.

+0

나는 이미 시도했다. @Giordano Maestro .. 아직도 그 오류가있어 ... – Raymond

0

"잘못된 요청을 사용하는 것이 <![CD[<soap:Body></soap:Body>]]> 시도 될 수

0

HttpURLConnection과 (과) 동일한 문제가 있습니다. 아래의 두 가지 속성을 추가하면 내 400 잘못된 요청 문제를 해결 :

  1. httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8");
  2. httpConn.setRequestProperty("soapAction", soapAction);

참고 : 응답을 읽으려고 할 때이 오류가 일반적으로 나타납니다.

+0

나는 이것을 필요로한다. 발행물. SOAP Envelope을 보내는 방법을 알려주시겠습니까? – joga

관련 문제