WFC Soap class within an class communicating with PHP

Within the Windows Foundation Classes you are able to create SOAP end points. These end points you are able to communicate using classes funny enough (because of the WFC being classes). But to communicate with these is fine with PHP and also when you sometimes have a class within an class as a parameter passing to the SOAP end point. Well you are able to do it within PHP as well.

If you have a WFC service and add these to the service for the ServiceContract and create the DataContract’s and DataMembers

public interface IService1
    string NewValue(NewName name);
public class SecondName
    int svalue1;
    int svalue2;
    public int Svalue1
        get { return svalue1; }
        set { svalue1 = value; }
    public int Svalue2
        get { return svalue2; }
        set { svalue2 = value; }
public class NewName
    SecondName secondValue = new SecondName();
    public SecondName SecondValue
        get { return secondValue; }
        set { secondValue = value; }

Created the SecondName class as the second named class with the svalue1/2 within in turn the NewName named class will reference the SecondName class.

And then within the class that implements the interface here is the function name to call within the soap end point called NewValue.

public string NewValue(NewName namesec)
    return string.Format("Value : {0}", namesec.SecondValue.Svalue1 + namesec.SecondValue.Svalue2);

Well to find out what you need to pass to the soap call I was using an WFC application to write out the debugging information with altering the web.config by

      <source name="System.ServiceModel.MessageLogging">
          <add name="messages"
          initializeData="c:\temp\messages.svclog" />

which in turns creates a file and in that file there is xml definition what is being sent.

 <NewValue xmlns="">
 <name xmlns:d4p1="" xmlns:i="">

and within PHP you are able to copy this. but note that the parameter to send is “name” which is not the same as the parameter above (namesec) you have to send to “name” which is what the soap end point is looking for.

class SecondName {
    public $Svalue1;
    public $Svalue2;
class NewName {
    public $SecondValue;
    public function NewName($s1, $s2)
        $this->SecondValue = new SecondName();
        $this->SecondValue->Svalue1 = $s1;
        $this->SecondValue->Svalue2 = $s2;
$objN = new NewName(200,100);
//Create a SOAP client
$client = new SoapClient("");
$retVal = $client->NewValue(array ("name" => $objN));

and the output is

Value : 300

Have attached a file of the project for the WFC webserver and also the php code.

Leave a Reply

Your email address will not be published. Required fields are marked *