2013-02-15 57 views
0

我有一個從我的WSDL生成的JAX-WS 2.0 Web服務實現。JAX-WS |在邏輯處理程序中獲取操作名稱

我需要在我的邏輯處理程序實現中訪問Web服務操作名稱。

我使用以下來解決這個問題,但它總是返回null。

context.get(MessageContext.WSDL_OPERATION);

如果你們中的任何一位能幫我解決這個問題,那將是非常棒的。

我的服務器爲7.0,開發IDE是RAD 8

在此先感謝。

+0

可能的重複http://stackoverflow.com/q/13535277/1530938 – kolossus 2013-02-21 15:30:55

+1

@kolossus - 不是直接重複。你的鏈接問題指的是'SOAPHandler',這個問題涉及'LogicalHandler'。區別在於LogicalHandler將'LogicalMessageContext'傳遞給'handleMessage'方法,該方法的範圍比傳遞給'SOAPHandler.handleMessage()'的'MessageContext'的範圍更有限。 – majorbanzai 2013-06-14 23:03:29

回答

2

如果你想SOAPAction頭,它包含Web服務的名稱(如礦山做),你可以用它來打印:

private void inLogger(SOAPMessageContext context){ 
    HttpServletRequest req = (HttpServletRequest)context.get(MessageContext.SERVLET_REQUEST); 
    System.out.println(req.getHeader("SOAPAction")); 
} 
0

你可以試試這個方法:

1)設定參數通過的RequestContext:

Map<String, Object> requestCtx = dispatcher.getRequestContext(); 
requestCtx.put("operationName", "anyOperation"); 

2)檢查內部的handleMessage這個參數在WS LogicalHandler:

public boolean handleMessage(LogicalMessageContext messageContext) { 
    boolean isCustomOperation = messageContext.containsKey("operationName"); 
    if (isCustomOperation) { 
    // do smth.. 
    } 
    return true; 
} 
0

如果處理程序執行LogicalHandler<LogicalMessageContext>你可以做這樣的:

((QName)context.get(LogicalMessageContext.WSDL_OPERATION)).getLocalPart(); 

這將返回被調用的操作的名稱。