2012-01-10 56 views
0

這裏是我的SOAP請求:如何訪問Spring soap端點中的SOAP標頭?

<?xml version="1.0" encoding="UTF-8"?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:str="http://app.strategyblocks.com/ws/schema/strategyblocks"> 
    <soapenv:Header> 
     <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1"> 
      <wsse:UsernameToken xmlns:wsu="..."> 
       <wsse:Username>admin</wsse:Username> 
       <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">secret</wsse:Password> 
      </wsse:UsernameToken> 
     </wsse:Security> 
    </soapenv:Header> 
    <soapenv:Body> 
     <str:updateKpiRequest> 
      <str:company_id>1</str:company_id> 
      <str:kpi> 
       <str:external_id>1134511</str:external_id> 
       <str:title>title</str:title> 
       <str:description>description</str:description> 
      </str:kpi> 
     </str:updateKpiRequest> 
    </soapenv:Body> 
</soapenv:Envelope> 

這裏是我的端點類:

@Endpoint 
public class UpdateKpiEndpoint { 

    // The namespace of both request and response as declared in the XSD file 
    public static final String NAMESPACE_URI = "http://app.strategyblocks.com/ws/schema/strategyblocks"; 

    // The local name of the expected request. 
    public static final String REQUEST_LOCAL_NAME = "updateKpiRequest"; 

    @PayloadRoot(localPart = REQUEST_LOCAL_NAME, namespace = NAMESPACE_URI) 
    @ResponsePayload 
    public UpdateKpiResponse processUpdateKpi(@RequestPayload UpdateKpiRequest updateKpiRequest) { 
     try { 

     } catch (Exception e) { 
      UpdateKpiResponse response = new UpdateKpiResponse(); 
      response.setCode("FAILURE"); 
      response.setDescription("Problem with update kpi request"); 

      return response; 
     } 

     UpdateKpiResponse response = new UpdateKpiResponse(); 
     response.setCode("SUCCESS"); 
     response.setDescription("Kpi has been updated"); 

     return response; 
    } 

} 

目前我傳遞一個UsernameToken進行身份驗證的SOAP請求,這是所有工作的很好,我沒有任何問題,它是如此之多。我希望能夠實現的是從端點類中processUpdateKpi方法的標題中檢索該用戶名,以便我可以使用它來查找該用戶的現有數據,我試圖找到它的示例完成並且到目前爲止我已經失敗了,是否有可能做到這一點?我也考慮過在SOAP體內傳遞用戶名,但我想避免它。

+1

你有沒有想出解決辦法? – 2013-03-15 19:32:12

回答