I'm trying to use a .net soap webservice in php, I've tried everything but I keep getting the error "Object reference not set to an instance of an object". Here's the code I've got right now:
$client = New SoapClient('http://url.com/DesktopModules/IWebCSharp/webservice.asmx?WSDL', array('trace' => true));
$head = array();
$head['PortalID'] = 0;
$head['UserID'] = 1;
$head['Username'] = 'foo';
$head['Password'] = 'bar';
$head['Encrypted'] = 'false';
$head['WebPageCall'] = 'false';
$head['ModuleId'] = 523;
$header = new SoapHeader('http://schemas.xmlsoap.org/soap/envelope/', 'IWebAuthendication', $head);
$client->__setSoapHeaders($header);
$client->GetUser(array('GetUser' => array('someuser', 'Username')));
When I run this and check the request sent ($client->__getLastRequest()) I get the following:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://webservices.DotNetNuke.com/"><SOAP-ENV:Header><SOAP-ENV:IWebAuthendication><!-- ALL THE AUTHENTICATION STUFF //--></SOAP-ENV:IWebAuthendication></SOAP-ENV:Header><SOAP-ENV:Body><ns1:GetUser/></SOAP-ENV:Body></SOAP-ENV:Envelope>
The relevant part there is of course this:
<SOAP-ENV:Body><ns1:GetUser/></SOAP-ENV:Body>
Why am I not getting the parameter through? What am I doing wrong? I've searched a LOT, both here on SO and Google, but every solution I've seen that has been working for others is not working for me. This webservice is part of a DotNetNuke system and I can make this work if I use CURL so I know the webservice can't be broken but I really want to use SoapClient() calls instead because it's a lot easier and a lot less code.
Here is the relevant code from the .net webservice:
public UserInfo GetUser(string Username) {
UserInfo objResponse = new UserInfo();
try {
IWebAuthendication objIWebAuthendication = new IWebAuthendication(IWebCredentials);
if (!(objIWebAuthendication.ValidAndAuthorized())) {
objResponse.UserID = -1;
objResponse.Username = "Not Authorized";
return objResponse;
}
objResponse = IWebUser.GetUserInfo(IWebCredentials.PortalID, Username);
// Do not return the password for a administrator
if ((objResponse.IsSuperUser == false & objResponse.IsInRole("Administrators") == false)) {
objResponse.Membership.Password = UserController.GetPassword(ref objResponse, "").ToString();
}
else {
objResponse.Membership.Password = "Administrator password is supressed";
}
}
catch (Exception ex) {
objResponse.UserID = -1;
objResponse.Username = ex.Message;
}
return objResponse;
}
And here's the relevant part of the WSDL:
<wsdl:operation name="GetUser">
<soap:operation soapAction="http://webservices.DotNetNuke.com/GetUser" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
<soap:header message="tns:GetUserIWebAuthendicationHeader" part="IWebAuthendicationHeader" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
How can I make this work in PHP with SoapClient()?