Laravel空请求

时间:2017-04-10 13:41:00

标签: php xml laravel rpc xml-rpc

我试图找出使用Laravel 5.4处理xml-rpc 我正在使用Open HttpRequester向Laravel发送xml请求, 它返回200 OK状态代码,但我无法处理请求数据。

我只用一种方法(testMethod)将请求路由到控制器,其中包含以下内容:

public function testMethod(Request $request) {        
    $req = xmlrpc_decode_request($request, $method);
    print_r($req);
    print_r($request->toArray());           
}

我的XML看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
    <methodName>testMethod</methodName>
    <params>
        <param>
            <value>
                <string>Test value 1</string>
            </value>
        </param>
    </params>
</methodCall>

此请求仅返回一个空白数组。

我做错了什么?

编辑:

添加一些额外的代码。

路线:

Route::post('/request', 'RequestController@testMethod');

原始请求:

POST http://localhost/laratest/public/index.php/request
User-Agent: /
Host: localhost
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
    <methodName>testMethod</methodName>
    <params>
        <param>
            <value>
                <string>Test value 1</string>
            </value>
        </param>
    </params>
</methodCall>

响应: (我正在使用Open HttpRequester来查看响应) 浏览器模式:[]

明文模式:

Sfdump = window.Sfdump || (function(doc){var refStyle = doc.createElement(&#39; style&#39;),rxEsc = /([.*+?^${ }()| [] /\†)/ g,idRx = / \ bsf-dump- \ d + -ref [012] \ w + \ b /,keyHint = 0&lt; = navigator.platform.toUpperCase()。indexOf(&#39; MAC&#39;)?&#39; Cmd& #39;:&#39; Ctrl&#39;,addEventListener = function(e,n,cb){e.addEventListener(n,cb,false);};(doc.documentElement.firstElementChild || doc.documentElement.children [0])。appendChild(refStyle); if(!doc.addEventListener){addEventListener = function(element,eventName,callback){element.attachEvent(&#39; on&#39; + eventName,function(e){e .preventDefault = function(){e.returnValue = false;}; e.target = e.srcElement; callback(e);});};} function toggle(a,recursive){var s = a.nextSibling || {},oldClass = s.className,arrow,newClass; if(&#39; sf-dump-compact&#39; == oldClass){arrow =&#39;▼&#39 ;; newClass =&#39; sf-dump-expanded&#39 ;;} else if(&#39; sf-dump-expanded&#39; == oldClass){arrow =&#39;▶&#39 ;; newClass =&#39; sf-转储紧凑&#39 ;; } else {return false; } a.lastChild.innerHTML = arrow; s.className = newClass; if(recursive){try {a = s.querySelectorAll(&#39;。&#39; + oldClass); for(s = 0; s&lt; a.length; ++ s){if(a [s] .className!== newClass){a [s] .className = newClass; a [s] .previousSibling.lastChild.innerHTML = arrow; }}} catch(e){}}返回true; }; return function(root,x){root = doc.getElementById(root); var indentRx = new RegExp(&#39; ^(&#39; +(root.getAttribute(&#39; data-indent-pad&#39;)||&#39;&#39;)。replace(rxEsc ,&#39; \ $ 1&#39;)+&#39;)+&#39;,&#39; m&#39;),options = {&#34; maxDepth&#34;:1,&# 34; maxStringLength&#34;:160,&#34; fileLinkFormat&#34;:false},elt = root.getElementsByTagName(&#39; A&#39;),len = elt.length,i = 0,s,h ,t = []; while(i&lt; len)t.push(elt [i ++]); for(i in x){options [i] = x [i];函数a(e,f){addEventListener(root,e,function(e){if(&#39; A&#39; == e.target.tagName){f(e.target,e);} else if(&#39; A&#39; == e.target.parentNode.tagName){f(e.target.parentNode,e);} else if(e.target.nextElementSibling&amp;&amp;&#39; A& #39; == e.target.nextElementSibling.tagName){f(e.target.nextElementSibling,e,true);}}); }; function isCtrlKey(e){return e.ctrlKey || e.metaKey; } addEventListener(root,&#39; mouseover&#39;,function(e){if(&#39;&#39;!= refStyle.innerHTML){refStyle.innerHTML =&#39;&#39 ;;} }); a(&#39; mouseover&#39;,function(a,e,c){if(c){e.target.style.cursor =&#34; pointer&#34 ;;} else if(a = idRx。 exec(a.className)){try {refStyle.innerHTML =&#39; pre.sf-dump。&#39; + a [0] +&#39; {background-color:#B729D9;颜色:#FFF !important; border-radius:2px}&#39 ;;} catch(e){}}}); a(&#39;点击&#39;,功能(a,e,c){if(/\bsf-dump-toggle\b/.test(a.className)){e.preventDefault(); if(! toggle(a,isCtrlKey(e))){var r = doc.getElementById(a.getAttribute(&#39; href&#39;)。substr(1)),s = r.previousSibling,f = r.parentNode, t = a.parentNode; t.replaceChild(r,a); f.replaceChild(a,s); t.insertBefore(s,r); f = f.firstChild.nodeValue.match(indentRx); t = t。 firstChild.nodeValue.match(indentRx); if(f&amp;&amp; t&amp;&amp; f [0]!== t [0]){r.innerHTML = r.innerHTML.replace(new RegExp(&#39) ; ^&#39; + f [0] .replace(rxEsc,&#39; \ $ 1&#39;),&#39; mg&#39;),t [0]);} if(&#39 ; sf-dump-compact&#39; == r.className){toggle(s,isCtrlKey(e));}} if(c){} else if(doc.getSelection){try {doc.getSelection()。 removeAllRanges();} catch(e){doc.getSelection()。empty();}} else {doc.selection.empty();}} else if(/ \ bsf-dump-str-toggle \ b /。 test(a.className)){e.preventDefault(); e = a.parentNode.parentNode; e.className = e.className.replace(/ sf-dump-str-(expand | collapse)/,ap arentNode.className); }}; elt = root.getElementsByTagName(&#39; SAMP&#39;); len = elt.length; i = 0; while(i&lt; len)t.push(elt [i ++]); len = t.length; for(i = 0; i&lt; len; ++ i){elt = t [i]; if(&#39; SAMP&#39; == elt.tagName){elt.className =&#39; sf-dump-expanded&#39 ;; a = elt.previousSibling || {}; if(&#39; A&#39;!= a.tagName){a = doc.createElement(&#39; A&#39;); a.className =&#39; sf-dump-ref&#39 ;; elt.parentNode.insertBefore(a,elt); } else {a.innerHTML + =&#39; &#39 ;; } a.title =(a.title?a.title +&#39; \ n [&#39;:&#39; [&#39;)+ keyHint +&#39; + click]展开所有儿童&# 39 ;; a.innerHTML + =&#39;▼&#39 ;; a.className + =&#39; SF-转储拨动&#39 ;; x = 1; if(&#39; sf-dump&#39;!= elt.parentNode.className){x + = elt.parentNode.getAttribute(&#39; data-depth&#39;)/ 1; } elt.setAttribute(&#39; data-depth&#39;,x); if(x&gt; options.maxDepth){toggle(a);如果(&#39; sf-dump-ref&#39; == elt.className&amp;&amp;(a = elt.getAttribute(&#39; href&#39;))){a = a.substr (1); elt.className + =&#39; &#39; + A; if(/[[{]$/.test(elt.previousSibling.nodeValue)){a = a!= elt.nextSibling.id&amp;&amp; doc.getElementById(一);试试{s = a.nextSibling; elt.appendChild(一); s.parentNode.insertBefore(a,s); if(/^[@#]/.test(elt.innerHTML)){elt.innerHTML + =&#39; ▶&#39 ;; } else {elt.innerHTML =&#39;▶&#39 ;; elt.className =&#39; sf-dump-ref&#39 ;; } elt.className + =&#39; SF-转储拨动&#39 ;; } catch(e){if(&#39;&amp;&#39; == elt.innerHTML.charAt(0)){elt.innerHTML =&#39; ...&#39 ;; elt.className =&#39; sf-dump-ref&#39 ;; if(0&gt; = options.maxStringLength){return;}}}}}尝试{elt = root.querySelectorAll(&#39; .sf-dump-str&#39;); len = elt.length; i = 0; t = []; while(i&lt; len)t.push(elt [i ++]); len = t.length; for(i = 0; i&lt; len; ++ i){elt = t [i]; s = elt.innerText || elt.textContent; x = s.length - options.maxStringLength; if(0&lt; x){h = elt.innerHTML; elt [elt.innerText? &#39;的innerText&#39; :&#39; textContent&#39;] = s.substring(0,options.maxStringLength); elt.className + =&#39; SF-转储STR-崩溃&#39 ;; elt.innerHTML =&#39;&#39; + h +&#39; ◀&#39; +&#39;&#39; + elt.innerHTML +&#39; ▶&#39 ;; }}} catch(e){}}; })(文献); pre.sf-dump {display:block;白空间:pre;填充:5px; } pre.sf-dump span {display:inline; } pre.sf-dump .sf-dump-compact {display:none; } pre.sf-dump abbr {text-decoration:none; border:none;游标:帮助; } pre.sf-dump a {text-decoration:none;游标:指针;边界:0;大纲:无;颜色:继承; } pre.sf-dump .sf-dump-ellipsis {display:inline-block;溢出:可见;文本溢出:省略号;最大宽度:5em;白色空间:nowrap;溢出:隐藏; vertical-align:top; pre.sf-dump code {display:inline;填充:0;背景:无; } .sf-dump-str-collapse .sf-dump-str-collapse {display:none; } .sf-dump-str-expand .sf-dump-str-expand {display:none; pre.sf-dump,pre.sf-dump .sf-dump-default {background-color:#fff;颜色:#222;行高:1.2em;字体重量:正常;字体:12px Monaco,Consolas,monospace;自动换行:break-word;白色空间:预包装;位置:相对; z-index:100000} pre.sf-dump .sf-dump-num {color:#a71d5d} pre.sf-dump .sf-dump-const {color:#795da3} pre.sf-dump .sf-dump- str {color:#df5000} pre.sf-dump .sf-dump-cchr {color:#222} pre.sf-dump .sf-dump-note {color:#a71d5d} pre.sf-dump .sf-dump -ref {color:#a0a0a0} pre.sf-dump .sf-dump-public {color:#795da3} pre.sf-dump .sf-dump-protected {color:#795da3} pre.sf-dump .sf- dump-private {color:#795da3} pre.sf-dump .sf-dump-meta {color:#b729d9} pre.sf-dump .sf-dump-key {color:#df5000} pre.sf-dump .sf -dump指数{颜色:#a71d5d} [] Sfdump(&#34; SF-转储-2001561441&#34)

1 个答案:

答案 0 :(得分:1)

如果您要发布原始数据,我认为您可以使用set