我從我打來的服務中得到這個響應。我希望在Soap-UI中寫一個斷言來驗證<Result>
標記的值。如何找到此XML中的<Result>標記的XPath?
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<ServiceResponse> <!--Issue happens here when xmlns attribute is present-->
<ServiceResult xmlns:a="http://schemas.datacontract.org/2004/07/services.api.DataContracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<AdditionalInfo i:nil="true"/>
<ErrorMessage/>
<ErrorMessageId i:nil="true"/>
<ErrorMessages xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
<InternalId>0</InternalId>
<RecordsAffected>0</RecordsAffected>
<Result>false</Result>
<WarningMessages xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
<a:ReturnBase>
</a:ReturnBase>
</ServiceResult>
</ServiceResponse>
</s:Body>
</s:Envelope>
我用Xpath Testing tool online找到正確的路徑。當我刪除<ServiceResponse>
標記上的xmlns屬性時,XPATH將按預期工作。但是,當<ServiceResponse>
標籤上有xmlns="http://schema.Services"
時,XPath無法返回項目。
我也嘗試在Notepad ++中用XML Tools Plugin找到它,當我有<ServiceResponse xmlns="http://schema.Services">
時,它會拋出異常。
我該如何着手在soap-UI中編寫這個斷言?
您錯過了爲選定的Result元素提供XPath表達式,這是有問題的。可能的原因是您沒有正確指定要調用的XPath處理器的命名空間綁定來評估XPath表達式。你正在使用哪種XPath處理器?請編輯問題並提供這些重要的缺失信息。 – 2015-04-04 02:42:00