So, continuing from my last post, there's a missing chunk of documentation for PHP::SOAP, especially when it comes to interacting with .NET SOAP Servers. It's especially odd, because SOAP is one of the places where Microsoft seems to have written their code to exactly meet the standard; the problem probably isn't on the Microsoft end of things.
Again, we shut off the WS-Security specific to SOAP, and only used HTTP Authentication, by the customer's request. It seems that WS-Security uses a call to $client->setCredentials($user, $pass, 'basic), whereas HTTP Auth requires user/pass in the instantiation of the SoapClient.
Anyways, here's the example:
$user="bob";
$password='bobspassword';
$wsdl = "https://".$user.":".$password."@example.org/ws/supervisors/?wsdl";
$client = new SoapClient($wsdl, array("trace" => 1, "exceptions" => 0, "login" => $user, "password" => $password));
// Debugging information to show all functions described in the WSDL
$functions = $client->__getFunctions();
print_r($functions);
$types = $client->__getTypes();
print_r($types);
print "
";
// Call the SOAP service
$params->empId= "12345";
$response = $client->EmpToSuper($params);
// Display more debgging information
print_r($response);
print "\n";
";
// Display the request that was sent out
print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
// Display the response that came back
print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
print "
?>
PHP SOAP Continued
PHP:SOAP, open source hates working with Microsoft
Here at work, we have a .NET SOAP server. It essentially lets you find out three things: someone's manager, someone's managees, and someone's alternate user ID, given their SSN. It works just fine with .NET clients, and tests just fine accessed through a browser.
The problem is other departments using open source clients. One other department requested we turn off WS-Security, because their client wouldn't work with it. We moved to HTTP Authentication over an SSL connection, which should work just fine. Save one group couldn't make that work in Perl, so I put together the example:
#!/usr/bin/perl -w
use SOAP::Lite;
sub SOAP::Transport::HTTP::Client::get_basic_credentials { return 'bob'=>bobspassword'; }
my $soap = SOAP::Lite
-> uri('http://nowhere.org/ws/supervisors')
-> proxy('https://nowhere.org/ws/supervisors/Service.asmx')
-> on_action(sub{"http://nowhere.org/ws/supervisors/SupervisorTo
Employee"})
-> outputxml(1);
print $soap->SupervisorToEmployee(SOAP::Data->name(supervisorId => 'supervisor_id_here'))
;
Being I don't quite know Perl, at least that was fun. Today's challenge is that another group can't get PHP to play nice with the service, either. I tinkered with it yesterday, and the lack of documentation for PEAR::SOAP, the package they're using, is really sad. Being I don't quite know PHP, this could be interesting, as well.
