起初我有两个c ++服务器和客户端程序,分别在本地计算机上运行两个程序并在客户端输入一个名称,然后服务器将接收请求并发回电话号码并在客户端显示。在用gsoap编译之后,这就是我得到的wsdl文件。
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="test"
targetNamespace="test"
xmlns:tns="test"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:test="test"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/"
xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<schema targetNamespace="test"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:test="test"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
<!-- operation request element -->
<element name="getMobile">
<complexType>
<sequence>
<element name="user" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/><!-- test__getMobile::user -->
</sequence>
</complexType>
</element>
<!-- operation response element -->
<element name="getMobileResponse">
<complexType>
<sequence>
<element name="phone-num" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/><!-- test__getMobile::phone_num -->
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="getMobileRequest">
<part name="parameters" element="test:getMobile"/><!-- test__getMobile::test__getMobile -->
</message>
<message name="getMobileResponse">
<part name="parameters" element="test:getMobileResponse"/>
</message>
<portType name="testPortType">
<operation name="getMobile">
<documentation>Service definition of function test__getMobile</documentation>
<input message="tns:getMobileRequest"/>
<output message="tns:getMobileResponse"/>
</operation>
</portType>
<binding name="test" type="tns:testPortType">
<SOAP:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getMobile">
<SOAP:operation soapAction=""/>
<input>
<SOAP:body parts="parameters" use="literal"/>
</input>
<output>
<SOAP:body parts="parameters" use="literal"/>
</output>
</operation>
</binding>
<service name="test">
<documentation>gSOAP 2.8.3 generated service definition</documentation>
<port name="test" binding="tns:test">
<SOAP:address location="http://192.168.82.52:35088"/>
</port>
</service>
</definitions>
现在我应该在两个文件夹中创建两个独立的php文件,一个php文件应该足够了吗?我在互联网上检查一些代码,但仍不太确定在哪里进入... 谢谢!
对于我的c ++程序函数,如果我想在php中硬编码用户输入,我应该
$result = $sc->getMobile("Grace");
或者我可以把数组放进去吗?
答案 0 :(得分:1)
不确定您在这里要做什么 - 您是否正在尝试编写客户端程序?到目前为止你有什么?
您可以使用SimpleXMLElement解析从SOAP请求返回的xml字符串:
$xmlobj = new SimpleXMLElement($xmlstr);
位于此处的SimpleXMLElement参考:http://php.net/manual/en/class.simplexmlelement.php