A
A
AkruBas2016-05-23 21:49:37
PHP
AkruBas, 2016-05-23 21:49:37

How to form a SOAP request in non-wsdl mode in PHP?

Colleagues, I have the following correct SOAP request to a certain server:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateOrderBroker xmlns="http://tempuri.org/">
<shortApp xmlns:a="http://schemas.datacontract.org/2004/07/ScroogeCbformsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:PIB>John Doe</a:PIB>
<a:agreeId>3155</a:agreeId>
<a:formId>55</a:formId>
<a:stateCode>1234567890</a:stateCode>
<a:telephone>1511528945</a:telephone>
</shortApp>
</CreateOrderBroker>
</s:Body>
</s:Envelope>

There is also a working example in C# that generates this query:
public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        public EndpointAddress EndPointAddr {
            get { return
                new EndpointAddress("https://194.126.180.186:77/ScroogeCbForms.svc?wsdl");
            }
        }

        private void btnSend_Click(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback =
              new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);

            ServicePointManager.Expect100Continue = false;


            ServiceICreditTest.CreateOrderResponse response = new CreateOrderResponse();


            ScroogeSiteGist client = new ScroogeSiteGist(Binding(), EndPointAddr);
            shortApplicationBroker shortAp = new shortApplicationBroker()
            {
                agreeId = 3155, 
                PIB = "John Doe",
                stateCode = "1234567890",
                formId = 55,
                telephone = "1511528945"

            };
            //response = client.CreateOrder("1012021013");
            response = client.CreateOrderBroker(shortAp);

            txtText.Text = string.Format("id = {0} ErrorId = {1}", response.OrderId, response.ReturnValue);

        }

Similarly I am trying to do on PHP 5.3:
<?php
$client = new SoapClient("https://194.126.180.186:77/ScroogeCbForms.svc?wsdl", array('soap_version'   => SOAP_1_1, 'trace'   => 1));

$params = array(
    'agreeId' => 3155,
    'PIB' => 'John Doe',
    'stateCode' => '3289013768',
    'formId' => 55,
    'telephone' => '0661254877'
);

$client->CreateOrderBroker($params);

But I get the following request and server response:
<?php
...
echo "REQUEST:<pre>".htmlspecialchars($client->__getLastRequest()) ."</pre>";
echo "CALLBACK:<pre>".htmlspecialchars($client->__getLastResponse())."</pre>";

Request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body><ns1:CreateOrderBroker/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Answer:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body><CreateOrderBrokerResponse xmlns="http://tempuri.org/"><CreateOrderBrokerResult xmlns:a="http://schemas.datacontract.org/2004/07/ScroogeCbformsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:OrderId>0</a:OrderId>
<a:ReturnValue>Object reference not set to an instance of an object.</a:ReturnValue>
</CreateOrderBrokerResult>
</CreateOrderBrokerResponse>
</s:Body>
</s:Envelope>

As you can see, the request body is empty.
What does it mean? Is the WSDL schema wrong? Then why does the C# example form a non-empty request body?
And if the scheme is still wrong - help me construct the initial correct query manually?
And what is important - is there enough data to build it "by hand"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-05-23
@user004

classmap may need to be filled in? Not sure
php.net/manual/ru/book.soap.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question