2013-10-26 5 views
2

SOAP 웹 서비스 클라이언트에 초보자이며 클라이언트 생성 중에 오류가 발생합니다.SOAP Webservice Java 클라이언트

나를이이

//This is request that has to be send using SOAP Envelope 

POST /DISWebService/DISWebService.asmx HTTP/1.1 
Host: 192.168.2.119 
Content-Type: application/soap+xml; charset=utf-8 
Content-Length: length 

<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
    <soap12:Body> 
    <LoginSystem xmlns="http://tempuri.org/"> 
     <username>string</username> 
     <password>string</password> 
    </LoginSystem> 
    </soap12:Body> 
</soap12:Envelope> 

자바 코드

public static void main(String args[]) { 
    try { 
     // Create SOAP Connection 
    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory  .newInstance(); 
    SOAPConnection soapConnection = soapConnectionFactory 
        .createConnection(); 

      String url = "http://192.168.2.119/VISWebService/VISWebService.asmx"; 
      // String url = 
      // "http://192.168.2.119/DISWebService/DISWebService.asmx?op=LoginSystem"; 

      SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(),url); 

      // Process the SOAP Response 
      printSOAPResponse(soapResponse); 

      soapConnection.close(); 
     } catch (Exception e) { 
      System.err 
        .println("Error occurred while sending SOAP Request to Server"); 
      e.printStackTrace(); 
     } 
} 

private static SOAPMessage createSOAPRequest() throws Exception { 
     MessageFactory messageFactory = MessageFactory.newInstance(); 
     SOAPMessage soapMessage = messageFactory.createMessage(); 
     SOAPPart soapPart = soapMessage.getSOAPPart(); 


     String serverURI = "http://192.168.2.119/DISWebService/DISWebService.asmx"; 

     // SOAP Envelope 
     SOAPEnvelope envelope = soapPart.getEnvelope(); 

     // SOAP Body 
     SOAPBody soapBody = envelope.getBody(); 

     SOAPElement soapBodyElem = soapBody.addChildElement("LoginSystem"); 

     SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("username"); 
     soapBodyElem1.addTextNode("Chirendu"); 

     SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("password"); 
     soapBodyElem2.addTextNode("verve12*"); 

     MimeHeaders headers = soapMessage.getMimeHeaders(); 
     headers.addHeader("SOAPAction", serverURI); 

     soapMessage.saveChanges(); 

     /* Print the request message */ 
     System.out.print("Request SOAP Message = "); 
     soapMessage.writeTo(System.out); 
     System.out.println(); 

     return soapMessage; 
    } 

나 클라이언트를 만드는 데 도움이 바랍니다 해결하는 데 도움이 바랍니다.

+0

'soapConnection.call에서 사용되는 작업 예제를 사용)

이 오는 여부에 대한 응답 (createSOAPRequest(), url);'이것은 지정된 URL에 SOAP 요청을합니다. 어떤 목적으로 고객이 필요합니까? – Newbie

+0

주어진 웹 서비스를 사용하고 싶습니다. UI에 표시하려면 respone이 필요합니다. –

+0

올바르게 이해하면 웹 서비스 클라이언트가 완벽하게 작동하고 GUI를 묻는 중입니다. – home

답변

3

I)의 2 디버깅

1 단계를 제안 soapUI를 사용하여 확인합니다 여부를 내가 mykong

+0

초보자를위한 SOAPUI 사용은 SOAP 요청을 비교하여 쉽게 익힐 수 있습니다. –