2016-02-29 59 views
0

在一個沒有函數聲明的java服務中,函數調用在那裏,只有編譯時錯誤。但是輸出如預期的那樣沒有運行時錯誤。這怎麼可能?任何人都可以解釋嗎?Java服務錯誤 - webMethods

「方法functionName()未定義」是它顯示的錯誤。

以下是代碼。

 public static final void documentToStringVals(IData pipeline) 
     throws ServiceException { 

    // pipeline 
    IDataCursor pipelineCursor = pipeline.getCursor(); 
    String success = "false"; 
    IData inputDoc = null; 
    String outputValue = ""; 
    String headerYN = "N"; 
    boolean headerValue = false; 
    String delimiter = ","; 
    String newline = System.getProperty("line.separator"); 

    if (pipelineCursor.first("inputDocument")) { 
     inputDoc = (IData) pipelineCursor.getValue(); 
    } 
    else { 
     throw new ServiceException("inputDocument is a required parameter"); 
    } 

    if (pipelineCursor.first("delimiter")) { 
     delimiter = (String) pipelineCursor.getValue(); 
    } 

    if (pipelineCursor.first("headerYN")) { 
     headerYN = (String) pipelineCursor.getValue(); 
    } 
    if (headerYN.equalsIgnoreCase("Y")) { 
     headerValue = true; 
    } 

    try { 

     outputValue = docValuesToString(inputDoc, headerValue, delimiter); 

     outputValue += newline; 
     success = "true"; 
    } 

    catch (Exception e) { 
     System.out.println("Exception in getting string from document: " + e.getMessage()); 
     pipelineCursor.insertAfter("errorMessage", e.getMessage()); 
    } 
    pipelineCursor.insertAfter("success", success); 
    pipelineCursor.insertAfter("outputValue", outputValue); 
    pipelineCursor.destroy(); 
} 
+0

您正在使用什麼版本的WebMethods?你在使用Designer還是Developer?你確定運行時正在使用你的服務中的代碼(通過改變一些東西來確認這一點,看看更改是否在運行時發生 - 否則它可能會執行並且舊的.class文件)?你能發佈源代碼嗎? –

+0

我正在使用9.8設計器。代碼被使用並且只有通過調用該函數,纔會將值分配給輸出變量。它按預期拋出輸出。 – Sowndarya

+0

我粘貼了代碼。請幫助。 – Sowndarya

回答

1

您發佈的代碼有沒有提到「functionName」,所以我懷疑有無論是在共享代碼段或在同一文件夾中其他Java服務對它的引用。鑑於文件夾中的所有Java服務都被編譯爲一個類,因此所有這些服務都需要一起編譯,這可能會導致在編譯上述服務時出現錯誤消息。