2013-02-05 6 views
1

I이 샘플 코드가 있습니다클라이언트에 대한 발송 방법을 찾을 수 없습니다 {}

private static final String endpoint = "https://www.***.**:443/WSEndUser?wsdl"; 

    public static void main(String[] args) throws SOAPException { 
     SOAPMessage message = MessageFactory.newInstance().createMessage(); 
     SOAPHeader header = message.getSOAPHeader(); 
     header.detachNode(); 
/* 
     SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); 
     envelope.setAttribute("namespace","namespaceUrl"); 
*/ 
     SOAPBody body = message.getSOAPBody(); 
     QName bodyName = new QName("getVServers"); 
     SOAPBodyElement bodyElement = body.addBodyElement(bodyName); 
     SOAPElement symbol = bodyElement.addChildElement("loginName"); 
     symbol.addTextNode("my login name"); 
     symbol = bodyElement.addChildElement("password"); 
     symbol.addTextNode("my password"); 

     SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection(); 
     SOAPMessage response = connection.call(message, endpoint); 
     connection.close(); 

     SOAPBody responseBody = response.getSOAPBody(); 
     SOAPBodyElement responseElement = (SOAPBodyElement)responseBody.getChildElements().next(); 
     SOAPElement returnElement = (SOAPElement)responseElement.getChildElements().next(); 
     if(responseBody.getFault()!=null){ 
      System.out.println("1) " + returnElement.getValue()+" "+responseBody.getFault().getFaultString()); 
     } else { 
      System.out.println("2) " + returnElement.getValue()); 
     } 
    } 

을 그리고 난이 오류가있어 :

1) S:Client Cannot find dispatch method for {}getVServers

을하지만 난 뭐죠 ... 방법이 있는지 잘못 알아?

+0

wsdl : https://www.vservercontrolpanel.de/WSEndUser?wsdl – David

답변

5

문제가 계속되면 WSDL도 게시하십시오.

1) {} (빈 네임 스페이스) 인 getVServers이라는 메서드를 찾을 수 없어 웹 서비스 호출이 실패합니다. 기본 네임 스페이스에

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Body> 
     <getVServers> 
      <loginName>my login name</loginName> 
      <password>my password</password> 
     </getVServers> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

getVServers :

요청이 같이 보입니다.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Body> 
     <ns:getVServers xmlns:ns="http://your-namespace-from-wsdl.com"> 
      <loginName>my login name</loginName> 
      <password>my password</password> 
     </ns:getVServers> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

네임 스페이스는 사용자가 작성하는 방법을 변경, 추가하기 위해서 bodyName : 그것은 네임 스페이스가 WSDL 정의에서 targetNamespace를해야 이런 일이되어야 또한

QName bodyName = new QName("http://your-namespace-from-wsdl.com", "getVServers", "ns"); 

loginNamepassword 할 수있다 elementFormDefault="qualified"이 XML 스키마에 설정되어 있거나 접두사가 있어야합니다 (요소에 form="qualified"이있는 경우).

2) URL 끝점에? wsdl이 없어야합니다.

3) HTTPS 웹 서비스에 연결하려고합니다. 인증서와 DefaultSSLFactory를 적절하게 설정했는지 확인하십시오.

+0

wsdl : https://www.vservercontrolpanel.de/WSEndUser?wsdl – David

+1

감사합니다. 문제는 네임 스페이스가 누락되었습니다. – David

+0

예. 나도! ;) – Mirko

관련 문제