2015-07-19 64 views
0

我爲post request testig做了一個簡單的測試表單。eXist-db XForms POST提交實例更新

我的簡單目標是:發送POST請求有兩個參數,在實例存儲服務器響應(服務器只是將收到的參數回形成的,不變的)

<xf:model> 
     <xf:instance id="request" xmlns=""> 
      <data> 
       <arg1>param1</arg1> 
       <arg2>param2</arg2> 
      </data> 
     </xf:instance> 

     <xf:instance id="response" xmlns=""> 
      <null/> 
     </xf:instance> 

     <xf:submission id="post-instance" 
         method="put" 
         replace="all" 
         instance="response" 
         resource="adderPost.xq" 
         ref="instance('request')" 
         serialization="application/xml" 
         mediatype="application/xml" 
         includenamespaceprefixes="" 
         > 
     </xf:submission> 
    </xf:model> 

</head> 
<body> 
    <h1>XForm interaction with XQuery</h1> 
    <xf:input ref="instance('request')/arg1" incremental="true"> 
     <xf:label>Arg1:</xf:label> 
    </xf:input> 
    <br/> 
    <xf:input ref="instance('request')/arg2" incremental="true"> 
     <xf:label>Arg2:</xf:label> 
    </xf:input> 
    <br/> 
    <xf:output ref="instance('response')/result"> 
     <xf:label> Response:</xf:label> 
    </xf:output> 
    <br/> 

    <xf:submit submission="post-instance"> 
     <xf:label>Post</xf:label> 
    </xf:submit> 
    <p id="status"></p> 
</body> 

如果我使用參數替換=「所有」 ,如在上面的代碼中示出,但是服務器返回應答:

<?xml version="1.0" encoding="UTF-8"?> 
<result> 
    <arg1>param1</arg1> 
    <arg2>param2</arg2> 
</result> 

但是,如果使用參數 替換=「實例」 實例=「響應」

這一種情況:

throw 'allowScriptTagRemoting is false.'; 
    (function(){ 
    var r=window.dwr._[0]; 
    //#DWR-INSERT 
    //#DWR-REPLY 
    r.handleCallback("2","0",[{bubbles:true,cancelable:false,contextInfo:{"resource-uri":"http://10.40.171.50:8080/exist/apps/RBS_path/adderPost.xq", 
"response-headers":[null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */,null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */,null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */,null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */,null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */], 
targetId:"post-instance",targetName:"submission", 
"response-reason-phrase":"OK", 
"response-status-code":200.0},currentTarget:null,eventPhase:1, 
propertyNames:["resource-uri","response-headers","targetId","targetName","response-reason-phrase", 
"response-status-code"],target:null,timeStamp:1437294248749, 
type:"xforms-submit-done"}]); 
    })(); 

Response Headers: 
Content-Length:935 
Content-Type:text/javascript; charset=utf-8 
Date:Sun, 19 Jul 2015 08:24:08 GMT 
Server:Jetty(8.1.9.v20130131) 

回答