New job for the third week, for more than 3 years. Net, suddenly sharp turns to do php, drift over the bend, speed 180 miles
Because of the consolidation of data, the project has to use PHP to call the WCF
A fog, online related information less and less, in Phpchina send a post, no one back, it seems that the blog park is forever home
Thank Dudu the great God for his tireless reply to help, Thanks
========== The following is the body ===============
Using PHP to call WCF very simple, all the process, only need two words, carefully
First, the preparatory work:
1.soap.dll
See if there is php_soap.dll in the PHP installation package [PHP is automatically integrated, normally there will be, there is no online download]
2. Modify the php.ini file
After the first step of confirmation, continue to find the PHP configuration file. Because each person's environment is different, for example, the use of integrated development environment, one-click Installation
Some students are themselves installed separately, may php.ini the location will be different. This is done by using phpinfo () to view
After the file is found, open the file,
Find it.
; Extension=php_soap.dll
This line, and then remove the preceding semicolon.
If you do not find this line, do not worry, you can manually add this line.
3. Restart Apach
Second, call WCF
After the 123 steps are completed, our preparation is complete and the next step is to write the code
Assuming that everyone will be WCF, there is a basis for PHP
1. Publish a WCF to invoke
Here are the two methods of WCF
public string SayHello ()
{
Return "Hello World";
}
public string GetData (string value)
{
Return "You entered is:" + value;
}
2.PHP End Call
$wcfURL = ' http://192.168.3.102/Service1.svc?wsdl ';//"This is the address of WCF"
$wcfClient = new SoapClient ($wcfURL);
$result 1 = $wcfClient->sayhello ();
Print_r ($result 1);
Echo ' <br> ';
Echo $result 1->sayhelloresult;//Here is sayhello+result together write, specific reason I don't know
The above PHP code should normally output the following
StdClass Object ([sayhelloresult] = Hello World)
Hello World
The first method is called successfully.
We continue to invoke the method with parameters
This time, be sure to test the WCF Test client with WCF
See I start with the WCF method, the parameter is GetData (string value), and here is the T, which is because in WCF is a colleague who helps me write, he is lazy, and writes the GetData (string T) directly at the time of definition. For this lazy, paid a heavy code, a full 10 minutes!
Connection Details: http://q.cnblogs.com/q/71331/
The following is the revised PHP code
$args = Array (' t ' = ' 312 '); $wcfClient->getdata ($args);
echo $result->getdataresult;
Echo ' <br> ';
Print_r ($result);
The above normal output should be
You entered is:312
StdClass Object ([Getdataresult] = you entered is:312)
This completes the PHP call to WCF, of course, some of the small partners will ask the advanced point, such as the whole class or something as a parameter, return a class or something .... Weak weak said, have not played to so high-level.
Thanks again, Dudu.
The following is a reference article: http://blog.csdn.net/love__coder/article/details/6067611
Http://www.cnblogs.com/tianbang/archive/2012/05/07/2489149.html
PHP calls WCF summary