PHP POST SOAP和接收结果

Is it possible to post SOAP request to server url via PHP and receive result?

Url, which to post parameters:

http://example.com/stockChart.svc

Post parameters:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <getStockWeeklyChart xmlns="http://www.example.com/1">
            <request xmlns:d4p1="http://www.example.com/2" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <d4p1:msInstrumentID>0</d4p1:msInstrumentID>
                <d4p1:symbol>FB</d4p1:symbol>
                <d4p1:indexSymbol>0S&amp;P5</d4p1:indexSymbol>
                <d4p1:dateInfo xmlns:d5p1="http://www.example.com/3">
                    <d5p1:startDate>2012-05-18T00:00:00</d5p1:startDate>
                    <d5p1:endDate>2013-09-16T00:00:00</d5p1:endDate>
                    <d5p1:frequency>Weekly</d5p1:frequency>
                    <d5p1:frequencyUnit>1</d5p1:frequencyUnit>
                    <d5p1:tickCount>0</d5p1:tickCount>
                </d4p1:dateInfo>
            </request>
        </getStockWeeklyChart>
    </s:Body>
</s:Envelope>

Yes, indeed. Let's take an example of a WCF service being consumed by PHP:

using System;
using System.Globalization;
using System.Web.Services.Protocols;
using SalesforceService.SFDCPartner;
using System.Xml;

namespace SalesforceService
{
    public class SalesforceService : ISalesforceService
    {

        /// <summary>
        /// Simple test stub to see how PHP can communicate with .NET web service
        /// </summary>
        /// <param name="value">Any string, preferably simple like Hello or Bye</param>
        /// <returns>A string indicating the call received incoming value</returns>
        public string GetData(string value)
        {
            return string.Format("You entered: {0}", value);
        }


        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                throw new ArgumentNullException("composite");
            }
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }

    }
}

Corresponding Interface is:

using System;
using System.Runtime.Serialization;
using System.ServiceModel;

namespace SalesforceService
{
    [ServiceContract]
    public interface ISalesforceService
    {
        [OperationContract]
        string GetData(string value);
    }

    [DataContract]
    public class CompositeType
    {
        bool _boolValue = true;
        string _stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return _boolValue; }
            set { _boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return _stringValue; }
            set { _stringValue = value; }
        }
    }
}

PHP script that communicates with this service:

<?php   

    $client = new SoapClient("http://server.com/salesforceservice/SalesforceService.svc?wsdl");
    $result = $client->GetData(
        array('value'   => 'really?')
    );
    echo $result->GetDataResult, "
";

?>

Ensure that your php.ini is set up correctly and extension=php_soap.dll is uncommented. You may also need extension_dir = "ext" uncommented.