簡體   English   中英

如何使用RestFixture編寫POST / PUT請求

[英]How to write POST / PUT requests using RestFixture

我正在嘗試將smartrics-RestFixture-3.0-bin.zip用於POST請求,但由於某些原因而失敗。 看起來好像是服務問題,但是在我學習Fitnees時,不確定測試是否也有問題。

任何人都可以分享一些詳細信息,或使用演示REST API使用RestFixture / Wiki格式共享POST休息請求的示例-http: //www.thomas-bayer.com/sqlrest/CUSTOMER/

我的基於Wiki的TC如下所示-(我正在嘗試添加ID = 20的客戶數據)

'''Trying to add customer 20 entry'''
!| smartrics.rest.fitnesse.fixture.FitRestFixture | http://www.thomas-bayer.com/sqlrest/CUSTOMER/ |
| setBody | <CUSTOMER xmlns:xlink="http://www.w3.org/1999/xlink"><ID>20</ID><FIRSTNAME>Anne1</FIRSTNAME><LASTNAME>Miller1</LASTNAME><STREET>201 Upland Pl.</STREET><CITY>Lyon1</CITY></CUSTOMER> |
| POST    | /20| 200 | | |

我低於錯誤:

<html><head><title>Apache Tomcat/7.0.26 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.26</h3></body></html>

請提出建議。 謝謝!

更新時間:2015年4月6日

我試圖使用不正確的POST方法添加新的CUSTOMER條目,我應該使用PUT方法。 今天,當我嘗試使用PUT方法添加新的CUSTOMER條目時,出現了相同的錯誤:( ..

看起來僅是Web服務存在問題。

服務是否正常工作,如果將同一正文發送給其他機構,您會得到不同的響應嗎? (當我將您的身體發送到相同的網址時,會出現相同的錯誤。)

該錯誤似乎表明您正在調用的服務已損壞。 有時,這也可能是使用不正確的結果。

從目前的情況來看,您的問題似乎與FitNesse無關,而與您使用的服務有關。

在將setHeaders部分添加到我的Wiki之前,我遇到了同樣的錯誤。 在setBody之后嘗試以下操作:

| setHeaders | Content-Type:application / xml |

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM