2011-01-03 2 views
1

SOAP 인증이 필요한 .NET에서 작성된 웹 서비스를 사용하려고합니다. 가장 관심을 가질 부분은 다음과 같습니다.비누 인증 헤더가있는 Netbeans에서 .NET 웹 서비스를 사용하는 방법

<s:element name="SoapAuthenticationHeader" type="tns:SoapAuthenticationHeader" /> 
     <s:complexType name="SoapAuthenticationHeader"> 
     <s:sequence> 
      <s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" /> 
     </s:sequence> 
     <s:anyAttribute /> 
     </s:complexType> 

Netbeans에서 웹 서비스를 성공적으로 사용할 수 있습니다. 자동 생성 스텁/메소드에서는 인증을 위해 사용자 이름과 암호를 넣을 수 없으므로 사용할 수 없습니다. 내가 JAX-WS를 사용하는 경우

JAX-WS 가장에서

try { // Call Web Service Operation 
      org.tempuri.TeleCast service = new org.tempuri.TeleCast(); 
      org.tempuri.TeleCastSoap port = service.getTeleCastSoap(); 
      // TODO initialize WS operation arguments here 
      int campaignid = 0; 
      java.lang.String to = ""; 
      java.lang.String from = ""; 
      java.lang.String subject = ""; 
      java.lang.String body = ""; 
      java.lang.String uniqueid = ""; 
      // TODO process result here 
      boolean result = port.queueRealTimeEmail(campaignid, to, from, subject, body, uniqueid); 
      System.out.println("Result = "+result); 
     } catch (Exception ex) { 
      // TODO handle custom exceptions here 
     } 

JAX-RPC

try { // This code block invokes the TeleCastSoap:queueRealTimeEmail operation on web service 
      telecastclient.TeleCast teleCast = new telecastclient.TeleCast_Impl(); 
      telecastclient.TeleCastSoap teleCastSoap = teleCast.getTeleCastSoap(); 
      teleCastSoap.queueRealTimeEmail(/* TODO enter operation arguments*/); 
     } catch(javax.xml.rpc.ServiceException ex) { 
      java.util.logging.Logger.getLogger(telecastclient.TeleCast.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 
     } catch(java.rmi.RemoteException ex) { 
      java.util.logging.Logger.getLogger(telecastclient.TeleCast.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 
     } catch(Exception ex) { 
      java.util.logging.Logger.getLogger(telecastclient.TeleCast.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 
     } 

:

넷빈즈의 자동 스텁은 다음을 포함되어 생성 메서드를 사용하면 사용자 이름과 암호를 설정할 수있는 SoapAuthenticationHeader라는 클래스가 생깁니다. 하지만 다양한 작업을 수행하기 전에 또는 웹 서비스 호출을 수행하는 동안 SoapAuthenticationHeader 객체를 전달하는 방법을 모르겠습니다.

org.tempuri.SoapAuthenticationHeader auth = new SoapAuthenticationHeader(); 
      auth.setUsername("username"); 
      auth.setPassword("password"); 

JAX-RPC 방법에서는이 옵션이 없습니다.

위의 내용은 크게 감사하겠습니다. 시간 내 주셔서 감사드립니다.

답변

0

기본 Netbeans IDE 내에서이 작업을 수행 할 수있는 우아한 방법이없는 것처럼 보입니다.

Eclipse와 모든 검색에서 동일한 결과를 보았습니다. Apache Axis2 - Eclipse 용 Eclipse 플러그인 플러그인 마법사 (아직 링크를 게시 할 수 없습니다. 초보자).

위의 플러그인 (WSDL2Java의 일종 애드온)을 사용하면 유효성 검사를 위해 전달할 수있는 적절한 SoapAuthenticationHeader 객체와 함께 스텁이 생성됩니다.

그래서 내 코드는 지금 : 그것은 잘 작동

TeleCastStub stub = new TeleCastStub(); 

SoapAuthenticationHeader auth = new SoapAuthenticationHeader(); 
auth.setUsername(username); 
auth.setPassword(password); 

QueueRealTimeEmail pageObj = new QueueRealTimeEmail(); 
pageObj.setFrom(from); 
pageObj.setTo(to); 
pageObj.setSubject(subject); 
pageObj.setBody(body); 

SoapAuthenticationHeaderE authE = new SoapAuthenticationHeaderE(); 
authE.setSoapAuthenticationHeader(auth); 

QueueRealTimeEmailResponse response = stub.queueRealTimeEmail(pageObj, authE); 

. 가 그것을 할 수있는 올바른 방법이다,

  1. 그것에 대해 갔어요 방식에서, 축 2 플러그인을 사용하여, 내 코드 :

    지금이 더 몇 가지 질문에 날 리드? 때때로 나는 단지 작업을 수행하고 내가 더 나은 다음 시간을 할 수 있도록 항상 일을 할 수있는 올바른 방법을 찾는 관심 얻기 위해서 함께 해킹을 넣어 이 느낌을 얻을.

  2. 이클립스와 함께 내장 코드 생성 마법사를 사용할 때 나는 에 Axis2가 아닌 Ax 런타임에 대한 옵션이 있다는 것을 알게되었습니다.그래서 지금 내 질문입니다; 이전 버전의 Axis 또는 IDE의 사전 제작 도구를 사용하면 특수 인증 헤더가있는 웹 서비스를 사용하는 경우에만 을 수행 할 수 없습니까? 건축상의 한계가 더 많습니까?

시간을 내 주셔서 다시 한 번 감사드립니다.

대단한 보드 이쪽! 내 가죽을 여러 번 구해 주셨습니다. 이제는 지역 사회에 돌려주는 것이 나의 차례입니다.

관련 문제