一开始我有两个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");
还是放一个数组进去?
不确定您在这里要做什么-您正在尝试编写客户端程序吗?到目前为止你有什么发现?
您可以使用SimpleXMLElement解析从SOAP请求返回的xml字符串:
$xmlobj = new SimpleXMLElement($xmlstr);
SimpleXMLElement的参考位于这里:http://php.net/manual/en/class.simplexmlelement.php