格式化URL以调用PHP web服务函数

格式化URL以调用PHP web服务函数,php,web-services,url,Php,Web Services,Url,我试图直接从URL调用web服务函数 可通过以下方式访问web服务: ~mysite~/server.php?wsdl 这将显示所有web服务的列表。我正在尝试访问的是: <operation name="fetchSplash"> <documentation>Fetch Home Page</documentation> <input message="tns:fetchSplashIn"/> <output message="tns:

我试图直接从URL调用web服务函数

可通过以下方式访问web服务:

~mysite~/server.php?wsdl
这将显示所有web服务的列表。我正在尝试访问的是:

<operation name="fetchSplash">
<documentation>Fetch Home Page</documentation>
<input message="tns:fetchSplashIn"/>
<output message="tns:fetchSplashOut"/>
</operation>
所以我想我可以通过这样的方式来称呼它:

/server.php?wsdl/fetchSplash&sessionCode=A6C298B9-359143D6-A591-8D7016F0B72E&brand=1
但这也带来了:

<SOAP-ENV:Fault>
<faultcode>Sender</faultcode>
<faultstring>Invalid XML</faultstring>
</SOAP-ENV:Fault>

发件人
无效的XML

有人能告诉我是否可以直接从URL调用函数吗?

通过使用地址栏中的普通URL,不,这是不可能的(当然,除非有人在soap协议之上实现这一点)

soap的工作方式是使用一些xml作为有效负载执行http POST请求。这样(xml未经测试,可能不是100%正确):

POST/InStock HTTP/1.1
主持人:www.example.org
内容类型:应用程序/soap+xml;字符集=utf-8
内容长度:nnn
A6C298B9-359143D6-A591-8D7016F0B72E
1.

您应该能够使用一个可以定制http请求的应用程序将此请求发送到服务器(“针对chrome的Advanced Rest Client”就是一个例子)。

据我所知,还没有。你可以写一个脚本来帮你完成这个任务。脚本将把要调用的函数以及要传递的参数作为参数
/webserviceHandler.php?func=fetchSplash&sessionCode=mycode&brand=1
谢谢。我不知道高级Rest客户端。我去看看。
<SOAP-ENV:Fault>
<faultcode>Sender</faultcode>
<faultstring>Invalid XML</faultstring>
</SOAP-ENV:Fault>
POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
  <m:fetchSplash>
    <m:sessionCode>A6C298B9-359143D6-A591-8D7016F0B72E</m:sessionCode>
    <m:brand>1</m:brand>
  </m:fetchSplash>
</soap:Body>
</soap:Envelope>