如何从该xml生成php中的soap请求?
我厌倦了用SOAP发送请求。这是我的xml如何从该xml生成php中的soap请求?,php,xml,soap,request,Php,Xml,Soap,Request,我厌倦了用SOAP发送请求。这是我的xml <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:bpf="http://schemas.datacontract.org/2004/07/Bpf.Security.Common" xmlns:bpf1="http://schemas.datacontract.org/2
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:bpf="http://schemas.datacontract.org/2004/07/Bpf.Security.Common" xmlns:bpf1="http://schemas.datacontract.org/2004/07/Bpf.Security.Authentication.Common">
<soapenv:Header>
<InfoTag xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/BaufestProductivityFramework">
<ClientIp xmlns="http://schemas.datacontract.org/2004/07/Bpf.Common.Service">200.125.145.10</ClientIp>
<CompanyId xmlns="http://schemas.datacontract.org/2004/07/Bpf.Common.Service">1</CompanyId>
<UserName xmlns="http://schemas.datacontract.org/2004/07/Bpf.Common.Service">someUser</UserName>
</InfoTag>
</soapenv:Header>
<soapenv:Body>
<tem:LogIn>
<tem:token>
<bpf:type>
<bpf1:Description>someDesc</bpf1:Description>
<bpf1:Id>1</bpf1:Id>
<bpf1:Name>someDesc</bpf1:Name>
</bpf:type>
<bpf:password>somePass</bpf:password>
<bpf:userName>someUser</bpf:userName>
</tem:token>
</tem:LogIn>
</soapenv:Body>
</soapenv:Envelope>
我试图发送这个正文,我检查了soap错误的异常,但消息只返回“bad request NULL”
$params=new stdClass();
$params=新的SoapVar(“
萨默德斯
1.
名字
萨默帕斯
某个用户
“,XSD_ANYXML);
$response=$client->Login($params);
}
使用CURL,我可以发送这个XML并接收XML响应,但是使用SOAPClient,我不能发送这个请求
我希望有人能帮助我,谢谢
这是我在firebug中看到的代码,我唯一得到的是“坏请求”。当我使用uu getLastRequest()时,我看到了相同的。。。
我猜不应该正确发送头,但是_setSoapHeaders函数返回true。
这是输出:
<soap-env:envelope xmlns:ns1="http://tempuri.org/" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:header>
<soap-env:contextinformation>
<item>
<key>ClientIp</key>
<value>127.0.0.1</value>
</item>
<item>
<key>CompanyId</key>
<value>1</value>
</item>
<item>
<key>UserName</key>
<value>someUser</value>
</item>
</soap-env:contextinformation>
</soap-env:header>
<soap-env:body>
<tem:login>
<tem:token>
<bpf:type>
<bpf1:description>someDesc</bpf1:description>
<bpf1:id>1</bpf1:id>
<bpf1:name>someName</bpf1:name>
</bpf:type>
<bpf:password>somePass</bpf:password>
<bpf:username>someUser</bpf:username>
</tem:token>
</tem:login>
</soap-env:body>
</soap-env:envelope>
客户
127.0.0.1
公司ID
1.
用户名
某个用户
萨默德斯
1.
名字
萨默帕斯
某个用户
SoapHeader
相当随意地处理数组。如果您想使用数组,请考虑使用.< /P>
但是,您根本不需要数组,因为您只需要在头中构造一个元素。由于每个内部元素(例如,ClientIP)都有一个唯一的名称空间,因此不能只传入一个基本对象。相反,您必须使用SoapVar
类为每个元素指定一个特定的名称空间,该类允许您将普通的PHP数据包装在一个SoapClient
可以理解和翻译的“SOAP就绪”容器中
$innerNS = "http://www.w3.org/BaufestProductivityFramework";
$outerNS = "http://schemas.datacontract.org/2004/07/Bpf.Common.Service";
$tag = new stdClass();
$tag->ClientIP = new SoapVar("200.125.145.10", XSD_STRING, null, null, null, $innerNS);
$tag->CompanyId = new SoapVar(1, XSD_INT, null, null, null, $innerNS);
$tag->UserName = new SoapVar("someUser", XSD_STRING, null, null, null, $innerNS);
$client->__setSoapHeaders(new SoapHeader($outerNS, 'InfoTag', $tag));
最后,作为一项规则,不要手动编写XML强>考虑重新编写SOAP体代码,如这里所示的头代码。您应该能够专门处理XML的内容,而不是它的结构。我建议您开始调试问题,而不是猜测,在SoapClient中启用请求的跟踪模式,并查看它生成的XML:谢谢,我将尝试。。但是如果您更详细地看到,“InfoTag”有两个名称空间xmlns:i=”“和xmlns=“”,这不会影响我的请求?架构实例名称空间似乎不会在请求中的任何位置使用,因此,我希望省略它是安全的。我实现了使它工作,但我必须重写方法doRequest并操作DOMDocument,以使请求与原始xml相同。你能帮我处理尸体申请吗?我真的很想让事情正常运转。现在可以了,但是。。正在soapVar中编写xml。。。非常感谢你的帮助!谢谢你的帮助!
<soap-env:envelope xmlns:ns1="http://tempuri.org/" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:header>
<soap-env:contextinformation>
<item>
<key>ClientIp</key>
<value>127.0.0.1</value>
</item>
<item>
<key>CompanyId</key>
<value>1</value>
</item>
<item>
<key>UserName</key>
<value>someUser</value>
</item>
</soap-env:contextinformation>
</soap-env:header>
<soap-env:body>
<tem:login>
<tem:token>
<bpf:type>
<bpf1:description>someDesc</bpf1:description>
<bpf1:id>1</bpf1:id>
<bpf1:name>someName</bpf1:name>
</bpf:type>
<bpf:password>somePass</bpf:password>
<bpf:username>someUser</bpf:username>
</tem:token>
</tem:login>
</soap-env:body>
</soap-env:envelope>
$innerNS = "http://www.w3.org/BaufestProductivityFramework";
$outerNS = "http://schemas.datacontract.org/2004/07/Bpf.Common.Service";
$tag = new stdClass();
$tag->ClientIP = new SoapVar("200.125.145.10", XSD_STRING, null, null, null, $innerNS);
$tag->CompanyId = new SoapVar(1, XSD_INT, null, null, null, $innerNS);
$tag->UserName = new SoapVar("someUser", XSD_STRING, null, null, null, $innerNS);
$client->__setSoapHeaders(new SoapHeader($outerNS, 'InfoTag', $tag));