gpt4 book ai didi

php - 在发送请求之前,PHP是否针对WSDL验证请求?

转载 作者:行者123 更新时间:2023-12-03 08:58:05 29 4
gpt4 key购买 nike

我正在使用基于SOAP的API集成现有软件包和第三方软件包。但是,我无法从上一个请求中生成XML以帮助进行故障排除,因为我不相信实际会进行调用。我可以提出的唯一合乎逻辑的解释是,PHP在实际发送请求之前针对WSDL验证了请求。该代码对于这个问题不是必需的,为此,我尝试了太多的变体以选择一个或两个样本进行共享。我已经用有效的SOAP错误调用替换了该错误的SOAP调用,并且XML已生成并按预期成功返回。

有谁知道如何确定PHP是否正在发出请求并且请求失败,或者是否有可能让PHP根据WSDL使请求无效并根本无法进行调用?

如有疑问,请随时提问。感谢您的帮助!

最佳答案

尝试调试脚本以查看它是否确实在发出请求,PHP的SoapClient对象使此操作非常容易。看一看SoapClient::_getLastRequestSoapClient:: _getLastResponse

如果您想降低一些东西,ngrep是一个很好的简单工具,可让您随时了解线路上发生的事情。

采取这个简单的PHP脚本...

<?php
$client = new SoapClient('http://www.27seconds.com/kb/ws/Articles.asmx?WSDL');
$article = $client->GetArticle(array('articleId' => 7));

执行 ngrep port 80 &然后执行上面的脚本将转储通信,它看起来应该与此类似。
##
T 208.106.153.223:80 -> 10.0.2.15:40760 [AS]
..
##
T 10.0.2.15:40760 -> 208.106.153.223:80 [AP]
POST /kb/ws/Articles.asmx HTTP/1.1..Host: www.27seconds.com..Connection: Keep-Alive..User-Agent: PHP-SOAP/5.3.10-1ubuntu3.6..Content-Type: text/xml; charset=utf-8..
SOAPAction: "http://dsetzer.27seconds.com/ws/GetArticle"..Content-Length: 279....<?xml version="1.0" encoding="UTF-8"?>.<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://sc
hemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://dsetzer.27seconds.com/ws/"><SOAP-ENV:Body><ns1:GetArticle><ns1:articleId>7</ns1:articleId></ns1:GetArticle></SOA
P-ENV:Body></SOAP-ENV:Envelope>.
#
T 208.106.153.223:80 -> 10.0.2.15:40760 [A]
......
#
T 208.106.153.223:80 -> 10.0.2.15:40760 [A]
HTTP/1.1 200 OK..Date: Fri, 21 Jun 2013 21:11:21 GMT..Server: Microsoft-IIS/6.0..X-Powered-By: ASP.NET..X-AspNet-Version: 2.0.50727..Cache-Control: private, max-age
=0..Content-Type: text/xml; charset=utf-8..Content-Length: 4804....<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetArticleResponse xmlns="http://dsetzer.2
7seconds.com/ws/"><GetArticleResult><xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msda
ta"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element
name="Articles"><xs:complexType><xs:sequence><xs:element name="ArticleID" type="xs:int" minOccurs="0" /><xs:element name="ArticleTitle" type="xs:string" minOccurs="
0" /><xs:element name="ArticleSummary" type="xs:string" minOccurs="0" /><xs:element name="ArticleAuthorID" type="xs:int" minOccurs="0" /><xs:element name="ArticlePu
blishDate" type="xs:dateTime" minOccurs="0" /><xs:element name="AuthorName" type="xs:string" minOccurs="0" /><xs:element name="AuthorEmail" type="xs:string" minOccu
rs="0" /><xs:element name="AuthorHomepage" type="xs:string" minOccurs="0" /><xs:element name="ArticleBody" t
##
T 208.106.153.223:80 -> 10.0.2.15:40760 [AP]
ype="xs:string" minOccurs="0
##
T 208.106.153.223:80 -> 10.0.2.15:40760 [A]
" /><xs:element name="ArticleRating" type="xs:double" minOccurs="0" /></xs:sequence></xs:complexType></xs:element><xs:element name="Authors"><xs:complexType><xs:seq
uence><xs:element name="AuthorID" type="xs:int" minOccurs="0" /><xs:element name="AuthorName" type="xs:string" minOccurs="0" /><xs:element name="AuthorEmail" type="
xs:string" minOccurs="0" /></xs:sequence></xs:complexType></xs:element><xs:element name="Applicables"><xs:complexType><xs:sequence><xs:element name="appID" type="xs
:int" minOccurs="0" /><xs:element name="appDescr" type="xs:string" minOccurs="0" /></xs:sequence></xs:complexType></xs:element><xs:element name="Keywords"><xs:compl
exType><xs:sequence><xs:element name="KeyID" type="xs:int" minOccurs="0" /><xs:element name="KeyArticleId" type="xs:int" minOccurs="0" /><xs:element name="Keyword"
type="xs:string" minOccurs="0" /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="ur
n:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><NewDataSet xmlns=""><Articles diffgr:id="Articles1" msdata:rowOrder="0
"><ArticleID>7</ArticleID><ArticleTitle>Handle double quotes in a form.</ArticleTitle><ArticleSummary>When pulling data from a form or database you can into trouble
if the data contains a double quote (&amp;quot;).</ArticleSummary><ArticleAuthorID>1</ArticleAuthorID><Arti
##
T 208.106.153.223:80 -> 10.0.2.15:40760 [AP]
clePublishDate>2002-03-05T11
##
T 208.106.153.223:80 -> 10.0.2.15:40760 [A]
:40:54-05:00</ArticlePublishDate><AuthorName>Douglas L. Setzer, II</AuthorName><AuthorEmail>dsetzer@27seconds.com</AuthorEmail><AuthorHomepage>http://www.27seconds.
com</AuthorHomepage><ArticleBody>&lt;p&gt;..When I was dynamically populating form values, I found that if the data has a double quote (&amp;qout;) in it, it would
cut off the data entered in the form...&lt;/p&gt;....&lt;p&gt;..To solve this, I found that I could simple Server.HtmlEncode the value and all was well. Except whe
n I was populating from a database and the data was NULL which caused an error for Server.HtmlEncode. So, I whipped up this little function:..&lt;/p&gt;....&lt;p&g
t;..&lt;div style="width=450;height=300;overflow=scroll;"&gt;..&lt;pre&gt;..Function formEncode(formValue)..Dim m_sOut.. m_sOut = formValue.....If IsNull(m_sOut)
Then....m_sOut = ""...Else....m_sOut = Server.HTMLEncode(m_sOut)...End If.....formEncode = m_sOut....End Function..&lt;/pre&gt;..&lt;/div&gt;..&lt;/p&gt;....&lt;p&
gt;This is used when you assign a value to the form field:&lt;/p&gt;....&lt;p&gt;..&lt;div style="width=450;height=300;overflow=scroll;"&gt;..&lt;pre&gt;..&amp;lt;i
nput type="text" name="example" value="&amp;lt;%=formEncode("The ""test"" is good.") %&amp;gt;"&amp;gt;..&lt;/pre&gt;..&lt;/div&gt;..&lt;/p&gt;</ArticleBody></Artic
les><Authors diffgr:id="Authors1" msdata:rowOrder="0"><AuthorID>1</AuthorID><AuthorName>Douglas L. Setzer, I
##
T 208.106.153.223:80 -> 10.0.2.15:40760 [AP]
I</AuthorName><AuthorEmail>d
#
T 208.106.153.223:80 -> 10.0.2.15:40760 [AP]
setzer@27seconds.com</AuthorEmail></Authors><Applicables diffgr:id="Applicables1" msdata:rowOrder="0"><appID>1</appID><appDescr>Active Server Pages (ASP)</appDescr>
</Applicables><Keywords diffgr:id="Keywords1" msdata:rowOrder="0"><KeyID>386</KeyID><KeyArticleId>7</KeyArticleId><Keyword>CHR(34)</Keyword></Keywords><Keywords dif
fgr:id="Keywords2" msdata:rowOrder="1"><KeyID>388</KeyID><KeyArticleId>7</KeyArticleId><Keyword>DOUBLE QUOTE</Keyword></Keywords><Keywords diffgr:id="Keywords3" msd
ata:rowOrder="2"><KeyID>387</KeyID><KeyArticleId>7</KeyArticleId><Keyword>QUOTE</Keyword></Keywords></NewDataSet></diffgr:diffgram></GetArticleResult></GetArticleRe
sponse></soap:Body></soap:Envelope>
#root@precise64:~# ##
T 208.106.153.223:80 -> 10.0.2.15:40760 [A]
......
#
T 208.106.153.223:80 -> 10.0.2.15:40760 [AF]
......

注意到SOAP调用了吗?还有许多其他方法可以执行此操作,但是调试应该是您的第一站。 :)

祝好运,

安东尼

关于php - 在发送请求之前,PHP是否针对WSDL验证请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17243837/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com