Всем привет! Ребят, стоит такая задача: нужно получить некий ответ (данные) с SOAP-сервиса. Что имеется: 1. WSDL; 2. линк на сервис; 3. пример SOAP-запроса: <soapenv:Header> <UsernameToken xmlns="http://siebel.com/webservices">CASHSFR</UsernameToken> <PasswordText xmlns="http://siebel.com/webservices">We8h!bG0</PasswordText> <SessionType xmlns="http://siebel.com/webservices">Stateless</SessionType> </soapenv:Header>; 4. Примеры заявок, на которых можно тренироваться: 1-9CGkBS 1-AXQKaI 1-BHwU97N. Подскажите, люди добрые, как правильно сделать запрос, имея эти данные и получить нужный ответ? Известен даже метод, который нужно дёргать. Что было мною проделано: Код (Text): $client = new SoapClient('test_otpcbcash.wsdl', Array("exceptions"=>0,"trace" => 1)); // подключаю wsdl-файл var_dump($client->__getFunctions()); // смотрю, какие методы имеются Вижу: Код (Text): array(9) { [0]=> string(80) "registerAgreem_Output registerAgreem(registerAgreem_Input $registerAgreem_Input)" [1]=> string(80) "cancelOptyCash_Output cancelOptyCash(cancelOptyCash_Input $cancelOptyCash_Input)" [2]=> string(84) "checkOptyStatus_Output checkOptyStatus(checkOptyStatus_Input $checkOptyStatus_Input)" [3]=> string(72) "createAgreem_Output createAgreem(createAgreem_Input $createAgreem_Input)" [4]=> string(64) "authAgreem_Output authAgreem(authAgreem_Input $authAgreem_Input)" [5]=> string(80) "setCardAccount_Output setCardAccount(setCardAccount_Input $setCardAccount_Input)" [6]=> string(88) "cancelAuthAgreem_Output cancelAuthAgreem(cancelAuthAgreem_Input $cancelAuthAgreem_Input)" [7]=> string(80) "createOptyCash_Output createOptyCash(createOptyCash_Input $createOptyCash_Input)" [8]=> string(68) "checkAgreem_Output checkAgreem(checkAgreem_Input $checkAgreem_Input)" } Меня интересует метод checkOptyStatus. Вот не пойму, что ему передать в качестве аргументов? Также, разработчики дали пример вызова через соап метода checkOptyStatus: Код (Text): <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.otpcredit2.macc.com.ua"> <soapenv:Header> <UsernameToken xmlns="http://siebel.com/webservices">GHYL</UsernameToken> <PasswordText xmlns="http://siebel.com/webservices">Hdy7Heej</PasswordText> <SessionType xmlns="http://siebel.com/webservices">Stateless</SessionType> </soapenv:Header> <soapenv:Body> <ws:checkOptyStatus_Input> <ws:optyId>1-BHwU97N</ws:optyId> </ws:checkOptyStatus_Input> </soapenv:Body> </soapenv:Envelope>
Что именно глянуть? Код (Text): var_dump($client->__getTypes()); показывает: Код (Text): array(37) { [0]=> string(69) "struct registerAgreem_Input { string agreementId; string loginId; }" [1]=> string(69) "struct registerAgreem_Output { string errCode; string errMessage; }" [2]=> string(60) "struct cancelOptyCash_Input { string why; string optyId; }" [3]=> string(69) "struct cancelOptyCash_Output { string errCode; string errMessage; }" [4]=> string(48) "struct checkOptyStatus_Input { string optyId; }" [5]=> string(133) "struct checkOptyStatus_Output { string errCode; string errMessage; string negativeReason; string optyStage; string optyStatus; }" [6]=> string(45) "struct createAgreem_Input { string optyId; }" [7]=> string(104) "struct createAgreem_Output { string agreementId; string docUrl; string errCode; string errMessage; }" [8]=> string(64) "struct authAgreem_Input { string docUrl; string agreementId; }" [9]=> string(65) "struct authAgreem_Output { string errCode; string errMessage; }" [10]=> string(88) "struct setCardAccount_Input { string paymentPurpose; string optyId; string cardNum; }" [11]=> string(85) "struct setCardAccount_Output { string errCode; string errMessage; string result; }" [12]=> string(54) "struct cancelAuthAgreem_Input { string agreementId; }" [13]=> string(71) "struct cancelAuthAgreem_Output { string errCode; string errMessage; }" [14]=> string(55) "struct createOptyCash_Input { createOpty createOpty; }" [15]=> string(62) "struct createOptyCash_Output { OtpCBResponse OtpCBResponse; }" [16]=> string(49) "struct checkAgreem_Input { string agreementId; }" [17]=> string(134) "struct checkAgreem_Output { string agreementStatus; string archiveReason; string authStatus; string errCode; string errMessage; }" [18]=> string(52) "struct createOptyTopElmt { createOpty createOpty; }" [19]=> string(33) "struct createOpty { Opty Opty; }" [20]=> string(4656) "struct Opty { ListOfInsurance ListOfInsurance; string TIN; string addDocIssueDate; ListOfPhoto ListOfPhoto; string addDocIssuer; ListOfEstate ListOfEstate; string addDocNumber; ListOfIncomeSrc ListOfIncomeSrc; string addDocSeries; ListOfExpenses ListOfExpenses; string addDocType; ListOfCredit ListOfCredit; string addServiceAward; string addServiceToCredit; string address; string birthday; string businessPartner; string childCount; string citizenship; string clientIsPensioner; string clientIsStudent; string clientIsWorking; string clientPosition; string clientVector; string coOwner; string codeAgentInBroker; string codeNetwork; string codeTradePointInBroker; string company; string companyAddress; string companyCapitalType; string companyCorpus; string companyHouse; string companyIndex; string companyPhone1; string companyPhone2; string companyPhone3; string confirmIncomeForm; string contactFullName; string corpus; string costPaper; string costPaperDoc; string country; string credBank; string credComment; string creditFirsPay; string creditIsOpen; string creditTime; string curAddress; string curCorpus; string curFlat; string curHouse; string curIndex; string curPlace; string curTime; string dependentCount; string depositInOtherBank; string depositInOtherBankDoc; string docIssueDate; string docIssuer; string docNumber; string docSeries; string docType; string education; string email; string estate; string familyIncome; string flat; string founderComment; string founderEDRPOU; string founderName; string founderPart; string founderPartOther; string house; string index; string invoiceDate; string invoiceNumber; string isAccountInOtherBank; string isAddService; string isCredit; string isCreditOperation; string isDeterminateInfluence; string isFounder; string isMonthlyIncomeDocument; string isOTPMember; string isOTPServicer; string isOtherActive; string isOtherActiveDoc; string isOwnerCommercPlace; string isOwnerCommercPlaceDoc; string isOwnerFlat; string isOwnerFlatDoc; string isOwnerGround; string isOwnerGroundDoc; string isOwnerHouse; string isOwnerHouseDoc; string isOwnerOther; string isOwnerOtherDoc; string isOwnerTransport; string isOwnerTransportDoc; string isPrivateBusinessman; string isPublicWorker; string isUtilityPayment; string keyWord; string lastName; string maritalStatus; string maxFirstPay; string maxLoanSum; string maxPercent; string middleName; string minFirstPay; string minLoanSum; string minPercent; string model; string monthlyIncome; string name; string officeNumber; string otherActiveComment; string otherBankAccountNumber; string otherBankCode; string otherBankName; string otpComment; string otpConnection; string otpOtherComment; string overdueCredInOtherBank; string overdueCredInOtherBankDoc; string ownerOtherComment; string CardInsFlag; string OTPChannel; string blackListReason; string ownership; string personalIncome; string phoneContactFace; string phoneCurrent; string phoneInformation; string phoneMobile; string phoneMobile2; string phoneReg; string postIndexFlag; string privateBusinessRegDate; string privateBusinessRegNumber; string privateBusinessRegOrg; string privateBusinessView; string publicWorkerComment; string regAddress; string regCorpus; string regDate; string regFlat; string regHouse; string regIndex; string regPlace; string region; string releaseYear; string sector; string serviceCompany; string serviceProduct; string serviceType; string settlement; string sex; string spouseFullName; string spouseIsPensioner; string spouseIsStudent; string spouseIsWorking; string typeSettlement; string vendorCounty; string visualEvaluation; string workCategory; string workInCompanyTime; string companyCountry; string companyProvince; string companyRegion; string companyLocationType; string companyCity; string companyStreetType; string companyStreet; string regCountry; string regProvince; string regRegion; string regLocationType; string regCity; string regStreetType; string regStreet; string curCountry; string curProvince; string curRegion; string curLocationType; string curCity; string curStreetType; string curStreet; string postCountry; string postProvince; string postRegion; string postLocationType; string postCity; string postStreetType; string postStreet; string Channel; string postRegDate; string companyemp; string creditProductCode; string srcType; string OrgCode; string LoginName; string optyType; string contactRelation; string applicationAmount; }" [21]=> string(48) "struct ListOfInsurance { Insurance Insurance; }" [22]=> string(87) "struct Insurance { string30 InsuranceCompanyId; string30 ProductId; string50 Type; }" [23]=> string(36) "struct ListOfPhoto { Photo Photo; }" [24]=> string(95) "struct Photo { string FileName; base64Binary PhotoValue; string FileExt; string DocType2; }" [25]=> string(41) "struct ListOfEstate { Estate2 Estate2; }" [26]=> string(86) "struct Estate2 { string EstateCategory; string EstateOwner; string EstateComment; }" [27]=> string(48) "struct ListOfIncomeSrc { IncomeSrc IncomeSrc; }" [28]=> string(87) "struct IncomeSrc { string IncomeSource; string IncomeAmount; string IncomeComment; }" [29]=> string(45) "struct ListOfExpenses { Expenses Expenses; }" [30]=> string(91) "struct Expenses { string ExpenseCategory; string ExpenseAmount; string ExpenseComment; }" [31]=> string(39) "struct ListOfCredit { Credit Credit; }" [32]=> string(83) "struct Credit { string creditBank; string creditComment; string creditIsOpen2; }" [33]=> string(15) "string string50" [34]=> string(15) "string string30" [35]=> string(61) "struct OtpCBResponseTopElmt { OtpCBResponse OtpCBResponse; }" [36]=> string(73) "struct OtpCBResponse { string UUID; string code; string description; }"
Ну, не совсем текстовый, XML, но глазами смотрится Вообще - есть смысл воспользоваться специальными утилитами для работы с соапом. Например, SoapUI
Ребят, вот в WSDL смотрю есть часть кода, где упоминается метод checkOptyStatus: Код (Text): <portType name="checkOptyStatus"> <operation name="checkOptyStatus"> <input message="tns:checkOptyStatus_Input"></input> <output message="tns:checkOptyStatus_Output"></output> </operation> </portType> и вот ещё: Код (Text): <binding name="checkOptyStatus" type="tns:checkOptyStatus"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding> <operation name="checkOptyStatus"> <soap:operation soapAction="document/http://ws.xxxxxxxxxx:checkOptyStatus"></soap:operation> <input> <soap:body use="literal"></soap:body></input> <output> <soap:body use="literal"></soap:body> </output> </operation> </binding> Как это использовать, вернее, на что обратить внимание, чтобы вызвать метод checkOptyStatus?
Судя по тегам input и output, метод принимает на вход одну переменную типа "строка" и отдает тоже одну переменную типа "строка".
Ок, я пытаюсь вызвать этот метод следующим образом: Код (Text): $client = new SoapClient('test_otpcbcash.wsdl', Array("exceptions"=>1,"trace" => 0)); $result = $client->checkOptyStatus(array("optyId"=>"1-DYhfT")); // этот optyId присутствует print_r($result); Результат: Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error Code: 10944642 Error Message: Error: Inbound SOAP Message - Session Token is missing or invalid or has expired in /var/www/bua/admin/application_status/index.php:104 Stack trace: #0 /var/www/bua/admin/application_status/index.php(104): SoapClient->__call('checkOptyStatus', Array) #1 /var/www/bua/admin/application_status/index.php(104): SoapClient->checkOptyStatus(Array) #2 {main} thrown in /var/www/bua/admin/application_status/index.php on line 104 . Что не так?
Попробуйте SoapUI все-таки. Если ошибка сохранится, значит, проблемы на их стороне, если нет - у вас что-то с кодом. Первое, что требуется при дебаге - найти место ошибки.
Ребят, вопрос остаётся открытым. Нужно вызвать метод checkOptyStatus. В wsdl вижу, что его параметры не описаны, а описаны параметры checkOptyStatus_Input, кот. передаётся этому методу в качестве параметров. Код (Text): checkOptyStatus(checkOptyStatus_Input $checkOptyStatus_Input) string(48) "struct checkOptyStatus_Input { string optyId; }" Вот именно сюда мне и нужно передать array("optyId"=>"1-DYhfT"); Т.е. метод checkOptyStatus в чистом виде не принимает "optyId"=>"1-DYhfT", а принимает через checkOptyStatus_Input. Т.е. такая конструкция вызывает ошибку - Код (Text): $client->checkOptyStatus(array("optyId"=>"1-DYhfT")); Вот как сюда впихнуть этот checkOptyStatus_Input и ему в качестве параметров дать array("optyId"=>"1-DYhfT")?
Код (Text): Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error Code: 10944642 Error Message: Error: Inbound SOAP Message - Session Token is missing or invalid or has expired in /var/www/bua/admin/application_status/index.php:126 Stack trace: #0 /var/www/bua/admin/application_status/index.php(126): SoapClient->__call('checkOptyStatus', Array) #1 /var/www/bua/admin/application_status/index.php(126): SoapClient->checkOptyStatus('1-DYhfT') #2 {main} thrown in /var/www/bua/admin/application_status/index.php on line 126 Похоже он просит массив. Ему нужно что-то типа Код (Text): $result = $client->checkOptyStatus(checkOptyStatus_Input(array("optyId"=>"1-DYhfT"))); Но это Код (Text): Fatal error: Call to undefined function checkOptyStatus_Input() in /var/www/bua/admin/application_status/index.php on line 126 да и понятно.
Думаю, нужно передать хедер, т.е. залогиниться. Код (Text): $client = new SoapClient("test_otpcbcash.wsdl", array( "uri" => 'xxxxx', 'UsernameToken' => "xxxxx", 'PasswordText' => "xxxxx", 'SessionType' => "xxxxxx")); echo "Request :<br>". $client->__getLastRequest(). "<br>"; echo "Response :<br>". $client->__getLastResponse(). "<br>"; Почему-то не формируется запрос, Request и Response пустые.