跳轉至內容

WebObjects/Web 服務/常見問題和故障排除

來自華夏公益教科書

使用 Axis 呼叫 WebService 時出現 NullPointerException

[編輯 | 編輯原始碼]

如果你遇到以下異常

 Caused by: java.lang.NullPointerException
   at java.util.Hashtable.put(Hashtable.java:396)
   at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:395)
   at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:246)
   at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
   at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
   at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
   at org.apache.axis.client.Call.invoke(Call.java:2553)
   at org.apache.axis.client.Call.invoke(Call.java:2248)
     ... 5 more

這很可能是因為你使用的是 Java 1.5 和 Axis 1.1。如果你想讓你的客戶端在 Java 1.5 上執行,你需要升級到 Axis 1.2RC2。

使用 HTTPS 時出現 SAXParseException

[編輯 | 編輯原始碼]

如果在 WebObjects 5.4.x 中,你遇到透過 HTTPS(透過 WebObjects Apache 介面卡)連線到你的 Web 服務時出現異常,並出現以下錯誤

 org.xml.sax.SAXParseException: Premature end of file.
   at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source
   at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source))
     ... more

你需要在 file server.wsdd 檔案中新增更多資訊,以告知 Apache AXIS 在它認為傳輸機制是 'https' 時該怎麼做。AXIS 將根據 Apache WebObjects 介面卡轉發的 HTTP 頭部資訊做出此判斷。如果沒有條目告訴 AXIS 如何處理 'https',它將假設來自適配器的傳入資料透過 SSL 加密,即使介面卡和例項之間的通訊是明文的。要更改 AXIS 的行為,將 file server.wsdd 檔案從

<transport name="http">
 <requestFlow>
  <handler type="HTTPActionHandler"/>
  <handler type="URLMapper"/>
 </requestFlow>
</transport>

更改為

<transport name="http">
 <requestFlow>
  <handler type="HTTPActionHandler"/>
  <handler type="URLMapper"/>
 </requestFlow>
</transport>
<transport name="https">
 <requestFlow>
  <handler type="HTTPActionHandler"/>
  <handler type="URLMapper"/>
 </requestFlow>
</transport>

Axis 客戶端丟失會話

[編輯 | 編輯原始碼]

有關使用 Axis 客戶端的基於 cookie 的會話的更多資訊,請閱讀使用 Axis 在 Java 中使用部分。

華夏公益教科書