gpt4 book ai didi

php - 从给定的 WSDL 创建 PHP SOAP 服务

转载 作者:可可西里 更新时间:2023-11-01 12:53:36 25 4
gpt4 key购买 nike

这可能会被认为是一个非常懒惰的问题,但我向你保证它不是。我已经尝试了好几天让这个工作,但我就是做不到。

我得到了一个 WSDL 文件,我需要用 PHP 为它创建一个 SOAP 服务。谁能告诉我正确的做法是什么?

服务的接收者期望在调用 getMember 方法时返回一个“用户”对象。

这是 WSDL

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="getMember">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="memCode" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getMemberResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="getMemberResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getMemberByUsernameAndPassword">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="username" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getMemberByUsernameAndPasswordResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="getMemberByUsernameAndPasswordResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="insertMember">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="insertStr" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="insertMemberResponse">
<s:complexType/>
</s:element>
<s:element name="decodeID">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="memCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="decodeIDResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="decodeIDResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="encodeID">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="memCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="encodeIDResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="encodeIDResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="processPnrInfo">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="pnrXml" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="UserXml" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="extraCosts" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="processPnrInfoResponse">
<s:complexType/>
</s:element>
<s:element name="CancelPNR">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="paxSurname" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="pnrNo" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="CancelPNRResponse">
<s:complexType/>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="getMemberSoapIn">
<wsdl:part name="parameters" element="tns:getMember"/>
</wsdl:message>
<wsdl:message name="getMemberSoapOut">
<wsdl:part name="parameters" element="tns:getMemberResponse"/>
</wsdl:message>
<wsdl:message name="getMemberByUsernameAndPasswordSoapIn">
<wsdl:part name="parameters" element="tns:getMemberByUsernameAndPassword"/>
</wsdl:message>
<wsdl:message name="getMemberByUsernameAndPasswordSoapOut">
<wsdl:part name="parameters" element="tns:getMemberByUsernameAndPasswordResponse"/>
</wsdl:message>
<wsdl:message name="insertMemberSoapIn">
<wsdl:part name="parameters" element="tns:insertMember"/>
</wsdl:message>
<wsdl:message name="insertMemberSoapOut">
<wsdl:part name="parameters" element="tns:insertMemberResponse"/>
</wsdl:message>
<wsdl:message name="decodeIDSoapIn">
<wsdl:part name="parameters" element="tns:decodeID"/>
</wsdl:message>
<wsdl:message name="decodeIDSoapOut">
<wsdl:part name="parameters" element="tns:decodeIDResponse"/>
</wsdl:message>
<wsdl:message name="encodeIDSoapIn">
<wsdl:part name="parameters" element="tns:encodeID"/>
</wsdl:message>
<wsdl:message name="encodeIDSoapOut">
<wsdl:part name="parameters" element="tns:encodeIDResponse"/>
</wsdl:message>
<wsdl:message name="processPnrInfoSoapIn">
<wsdl:part name="parameters" element="tns:processPnrInfo"/>
</wsdl:message>
<wsdl:message name="processPnrInfoSoapOut">
<wsdl:part name="parameters" element="tns:processPnrInfoResponse"/>
</wsdl:message>
<wsdl:message name="CancelPNRSoapIn">
<wsdl:part name="parameters" element="tns:CancelPNR"/>
</wsdl:message>
<wsdl:message name="CancelPNRSoapOut">
<wsdl:part name="parameters" element="tns:CancelPNRResponse"/>
</wsdl:message>
<wsdl:portType name="ServiceSoap">
<wsdl:operation name="getMember">
<wsdl:input message="tns:getMemberSoapIn"/>
<wsdl:output message="tns:getMemberSoapOut"/>
</wsdl:operation>
<wsdl:operation name="getMemberByUsernameAndPassword">
<wsdl:input message="tns:getMemberByUsernameAndPasswordSoapIn"/>
<wsdl:output message="tns:getMemberByUsernameAndPasswordSoapOut"/>
</wsdl:operation>
<wsdl:operation name="insertMember">
<wsdl:input message="tns:insertMemberSoapIn"/>
<wsdl:output message="tns:insertMemberSoapOut"/>
</wsdl:operation>
<wsdl:operation name="decodeID">
<wsdl:input message="tns:decodeIDSoapIn"/>
<wsdl:output message="tns:decodeIDSoapOut"/>
</wsdl:operation>
<wsdl:operation name="encodeID">
<wsdl:input message="tns:encodeIDSoapIn"/>
<wsdl:output message="tns:encodeIDSoapOut"/>
</wsdl:operation>
<wsdl:operation name="processPnrInfo">
<wsdl:input message="tns:processPnrInfoSoapIn"/>
<wsdl:output message="tns:processPnrInfoSoapOut"/>
</wsdl:operation>
<wsdl:operation name="CancelPNR">
<wsdl:input message="tns:CancelPNRSoapIn"/>
<wsdl:output message="tns:CancelPNRSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getMember">
<soap:operation soapAction="http://tempuri.org/getMember" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getMemberByUsernameAndPassword">
<soap:operation soapAction="http://tempuri.org/getMemberByUsernameAndPassword" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="insertMember">
<soap:operation soapAction="http://tempuri.org/insertMember" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="decodeID">
<soap:operation soapAction="http://tempuri.org/decodeID" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="encodeID">
<soap:operation soapAction="http://tempuri.org/encodeID" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="processPnrInfo">
<soap:operation soapAction="http://tempuri.org/processPnrInfo" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="CancelPNR">
<soap:operation soapAction="http://tempuri.org/CancelPNR" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getMember">
<soap12:operation soapAction="http://tempuri.org/getMember" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getMemberByUsernameAndPassword">
<soap12:operation soapAction="http://tempuri.org/getMemberByUsernameAndPassword" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="insertMember">
<soap12:operation soapAction="http://tempuri.org/insertMember" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="decodeID">
<soap12:operation soapAction="http://tempuri.org/decodeID" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="encodeID">
<soap12:operation soapAction="http://tempuri.org/encodeID" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="processPnrInfo">
<soap12:operation soapAction="http://tempuri.org/processPnrInfo" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="CancelPNR">
<soap12:operation soapAction="http://tempuri.org/CancelPNR" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Service">
<wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
<soap:address location="[byng_wsdl_target]"/>
</wsdl:port>
<wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
<soap12:address location="[byng_wsdl_target]"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

如果有人能提供帮助,我将不胜感激。

额外的

class User {
public $GuestUserId;
public $Username;
public $FirstName;
public $SurName;
public $Email;
public
function getMember($uid) {
$applicant = new Applicant($uid);
$this->GuestUserId = $applicant->getIdentifier();
$this->Username = $applicant->getEmail();
$this->FirstName = $applicant->getFirstName();
$this->SurName = $applicant->getLastName();
$this->Email = $applicant->getEmail();
return $this;
}
}

最佳答案

在基本层面上,您应该能够使用类似这样的东西(未经测试/伪代码)进行 SOAP 调用:

$client = new SoapClient("http://somesite/service.wsdl");
$result = $client->getMember();
var_dump($result);

关于php - 从给定的 WSDL 创建 PHP SOAP 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8989512/

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