SOAP WSDL PHP client connecting to .Net Server - php

I need to integrate a web service, and its being like to days, and the closest I get is the following, maybe some of you have more experience than me in this kind of web service.
The XML request I need to generate is the following
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://v2.services.cangooroo.net/" xmlns:can="Cangooroo.Webservice.V2">
<soapenv:Header/>
<soapenv:Body>
<v2:getCityData>
<v2:credentialClient>
<can:UserName>?</can:UserName>
<can:Password>?</can:Password>
</v2:credentialClient>
<v2:countryId>US</v2:countryId>
</v2:getCities>
</soapenv:Body>
</soapenv:Envelope>
My PHP code
$client = new SoapClient("http://v2.cangooroo.net/ws/2013/common_a.asmx?WSDL", array(
"trace" => 1,
"compression" => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
));
$login = array();
$login[] = new SoapVar('*', XSD_STRING, null, null, 'UserName', 'Cangooroo.Webservice.V2' );
$login[] = new SoapVar('*', XSD_STRING, null, null, 'Password', 'Cangooroo.Webservice.V2' );
$rest = array();
$rest[] = new SoapVar($login, SOAP_ENC_OBJECT, null, null, 'credentialClient' );
$rest[] = new SoapVar('US', XSD_STRING, null, null, 'countryId');
$options = array('location' => 'http://v2.cangooroo.net/ws/2013/common_a.asmx');
try {
$resp = $client->__soapCall('getCityData', $rest, $options);
print_r($resp);
echo "Request:<pre>" . htmlentities($client->__getLastRequest()) . "</pre>";
}catch (SoapFault $e){
echo "REQUEST:<pre>" . htmlentities($client->__getLastRequest()) . "</pre>";
/*print_r($e);*/
The actual xml the PHP code above generates
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="Cangooroo.Webservice.V2" xmlns:ns2="http://ws_2013.services.cangooroo.net/">
<SOAP-ENV:Body>
<ns2:getCityData>
<ns1:UserName>*</ns1:UserName>
<ns1:Password>*</ns1:Password>
</ns2:getCityData><countryId>US</countryId></SOAP-ENV:Body></SOAP-ENV:Envelope>
Iam not really sure if this is the best way to do it, but I tryed others, with __soapCall,
__doRequest, this last one I got the soapClient php core class extended (as a try) to connect, and nothing seems to work. Pls, I could use a little help here. Tks guys.

If you check the wsdl file in http://v2.cangooroo.net/ws/2013/common_a.asmx?WSDL you can see the definition of the getCityData
<s:element name="getCityData">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="credential" type="s1:ClientCredential"/>
<s:element minOccurs="0" maxOccurs="1" name="countryId" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
the operation getCityData has a credential parameter, not a credentialClient that is what you have in the code that you posted. I've tried with this code:
$wsdlAddress = "http://v2.cangooroo.net/ws/2013/common_a.asmx?WSDL";
$options = array(
"soap_version" => SOAP_1_2,
"cache_wsdl" => WSDL_CACHE_NONE,
"exceptions" => false
);
$webServiceClient = new SoapClient($wsdlAddress, $options);
$requestData = array(
"countryId" => "US",
"credential" => array(
"UserName" => "username",
"Password" => "Password",
),
);
$response = $webServiceClient->__soapCall("getCityData", array("getCityData" => $requestData));
echo "<h2>getCityData Operation Test:</h2>";
echo "<pre>";
print_r($response);
echo "</pre>";
in the response i can see Err: Login_Fail - Invalid user or password., i think i'm getting a valid response. Try with my code and adapt it to your needs.
Happy coding

Related

soap api able to connect in SoapUI but not in PHP

I've been failing to consume a soap webservice with soapClient /nusoap I believe the issue might be with my header but I'm not sure as the error I get back are pretty vague at times.
We've been able to get it to work in SoapUI, which adds some additional things to the header notably this:
<wsa:Action>http://www.property24.com/services/IP24ListingServiceWcf/FetchAgents</wsa:Action><wsa:To>https://www.exdev.property24.com/Services/P24ListingService46.svc</wsa:To>
Its being added in SoapUI automaticaly by checking: add default WSA:to under WS-A
inside the header it also has xmlns:wsa="http://www.w3.org/2005/08/addressing" I dont know how to correctly set this if possible.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://www.property24.com/services">
<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<ser:CredentialsHeader>
<!--Optional:-->
<ser:EMail>..</ser:EMail>
<!--Optional:-->
<ser:Password>..!</ser:Password>
<!--Optional:-->
<ser:UserGroupEmailId>1</ser:UserGroupEmailId>
</ser:CredentialsHeader>
<wsa:Action>http://www.property24.com/services/IP24ListingServiceWcf/FetchAgents</wsa:Action><wsa:To>https://www.exdev.property24.com/Services/P24ListingService46.svc</wsa:To></soap:Header>
<soap:Body>
<ser:FetchAgents>
<!--Optional:-->
<ser:agencyId>..</ser:agencyId>
</ser:FetchAgents>
</soap:Body>
</soap:Envelope>
I'm getting a bad request response which I believe could be due to the header
this is what I've tried:
$headerbody = array(
'EMail' => $username,
'Password' => $password,
'UserGroupEmailId'=> $groupId
);
$headers[] = new SoapHeader('https://www.exdev.property24.com/', 'wsa:Action', "http://www.property24.com/services/IP24ListingServiceWcf/$method");
$headers[] = new SoapHeader('https://www.exdev.property24.com/', 'wsa:To', "https://www.exdev.property24.com/Services/P24ListingService46.svc");
$headers[] = new SoapHeader('https://www.exdev.property24.com/', 'CredentialsHeader', $headerbody);
$client->__setSoapHeaders($headers);
and
$header_part = '<CredentialsHeader><EMail>....</EMail><Password>....</Password><UserGroupEmailId>1</UserGroupEmailId></CredentialsHeader>';
$header_part .= '<wsa:Action>http://www.property24.com/services/IP24ListingServiceWcf/$method</wsa:Action><wsa:To>https://www.exdev.property24.com/Services/P24ListingService46.svc</wsa:To>';
$soap_var_header = new SoapVar($header_part, XSD_ANYXML, null, null, null);
$soap_header = new SOAPHeader('http://www.w3.org/2005/08/addressing', 'wsa',
$soap_var_header);
$client->__setSoapHeaders($soap_header);
I've not had a lot of experience with Soap webservices and have been stuck on this for quite some time thanks guys
construct header object by concatenating with user credentials
$headerStr= '
<ser:CredentialsHeader>
<!--Optional:-->
<ser:EMail>'.$username.'</ser:EMail>
<!--Optional:-->
<ser:Password>'.$password.'</ser:Password>
<!--Optional:-->
<ser:UserGroupEmailId>'.$groupId.'</ser:UserGroupEmailId>
</ser:CredentialsHeader>
<wsa:Action>http://www.property24.com/services/IP24ListingServiceWcf/FetchAgents</wsa:Action><wsa:To>https://www.exdev.property24.com/Services/P24ListingService46.svc</wsa:To>
';
$header= new \SoapHeader('http://www.w3.org/2005/08/addressing',
'wsa',
new \SoapVar($headerStr, XSD_ANYXML),
true
);
then construct SoapClient and set headers and operation name with parameters
$soapclient = new SoapClient($serviceURL,$options);
$soapclient-> __setSoapHeaders($header);
parameters can be sent as dictionary but very important to chang "Request" to be identical to the same name in service contract
$param=array ("Request" => array('agencyId'=>'123'));
$response =$soapclient->FetchAgents( $param);
var_dump(json_encode($response));
echo '<br><br><br>';
$array = json_decode(json_encode($response), true);
print_r($array);
the complete code snippet will be
try {
$options = [
"soap_version" => SOAP_1_2, // SOAP_1_1
'trace' => 1,
'exception' => 1,
'keep_alive' => false,
'connection_timeout' => 500000
];
$headerStr = '
<ser:CredentialsHeader>
<!--Optional:-->
<ser:EMail>' . $username . '</ser:EMail>
<!--Optional:-->
<ser:Password>' . $password . '</ser:Password>
<!--Optional:-->
<ser:UserGroupEmailId>' . $groupId . '</ser:UserGroupEmailId>
</ser:CredentialsHeader>
<wsa:Action>http://www.property24.com/services/IP24ListingServiceWcf/FetchAgents</wsa:Action><wsa:To>https://www.exdev.property24.com/Services/P24ListingService46.svc</wsa:To></soap:Header>
';
$header = new \SoapHeader(
'http://www.w3.org/2005/08/addressing',
'ws',
new \SoapVar($headerStr, XSD_ANYXML),
true
);
$soapclient = new SoapClient($serviceURL, $options);
$soapclient->__setSoapHeaders($header);
$param = array('agencyId' => '123');
$response = $soapclient->FetchAgents($param);
// print the last XML request to compare with the working one in soapUI
echo "REQUEST:\n" . $soapclient->__getLastRequest() . "\n";
var_dump(json_encode($response));
echo '<br><br><br>';
$array = json_decode(json_encode($response), true);
print_r($array);
} catch (Exception $e) {
echo $e->getMessage();
}

DHL PHP Express (DHL Global Webservices)

Hy all!
I try to do DHL Express, but I get caught up very much with DHL not really wanting to help. So I would like to ask for help.
And since I do not get back tracking numbers for anything just underlying XML, so I would like to ask for help. Thank you very much for helping me.
What I try:
// The url of the service
$url = 'https://wsbexpress.dhl.com:443/sndpt/expressRateBook?WSDL';
// the soap operation which is called
$action = 'createShipmentRequest';
// the xml input of the service
$xmlrequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rat="http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/RateMsgRequest">
<soapenv:Header>
<wsse:Security soapenv:mustunderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:id="UsernameToken-5" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>*********</wsse:Username>
<wsse:Password type="PasswordText">*******</wsse:Password>
<wsse:Nonce encodingtype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">eUYebYfsjztETJ4Urt8AJw==</wsse:Nonce>
<wsu:Created>' . date('Y-m-d H:i:s') . '</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
<soapenv:Header/>
<soapenv:Body>
<rat:RateRequest>
<RequestedShipment>
<DropOffType>REGULAR_PICKUP</DropOffType>
<Account>407194546</Account>
<Currency>EUR</Currency>
<UnitOfMeasurement>SI</UnitOfMeasurement>
<Ship>
<Shipper>
<StreetLines>Street number 22</StreetLines>
<City>City</City>
<PostalCode>111111</PostalCode>
<CountryCode>DE</CountryCode>
</Shipper>
<Recipient>
<StreetLines>Street number 22</StreetLines>
<City>City</City>
<PostalCode>111111</PostalCode>
<CountryCode>DE</CountryCode>
</Recipient>
</Ship>
<Packages>
<RequestedPackages number="1">
<Weight>
<Value>0.5</Value>
</Weight>
<Dimensions>
<Length>3</Length>
<Width>2</Width>
<Height>1</Height>
</Dimensions>
</RequestedPackages>
</Packages>
<ShipTimestamp>2018-07-18T08:00:00 GMT+0100</ShipTimestamp>
<Content>NON_DOCUMENTS</Content>
<PaymentInfo>DAP</PaymentInfo>
</RequestedShipment>
</rat:RateRequest>
</soapenv:Body>
</soapenv:Envelope>';
try {
// the soap client accepts options, we specify the soap version
// The trace option enables tracing of request so faults can be backtraced.
// The exceptions option is a boolean value defining whether soap errors throw exceptions of type SoapFault.
$opts = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$options = array(
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => 1,
'connection_timeout' => 180,
'stream_context' => stream_context_create($opts),
'cache_wsdl' => WSDL_CACHE_NONE,
);
// create the soapclient and invoke __doRequest method
$client = new SoapClient($url, $options);
$output = $client->__doRequest($xmlrequest, $url, $action, 1);
} catch (SoapFault $fault) {
echo "<h2>SOAP Fault!</h2><p>";
echo "FaultCode: {$fault->faultcode} <br/>";
echo "FaultString: {$fault->faultstring} <br/>";
echo"</p/>";
}
echo "<h2>WSDL URL: </h2><p>";
echo $url;
echo "</p/>";
echo "<h2>Action: </h2><p>";
echo $action;
echo "</p/>";
echo "<h2>XMLRequest: </h2><p>";
echo $xmlrequest;
echo "</p/>";
if (!isset($output)) {
echo "<h2>SOAP Fault!</h2><p>";
echo "FaultCode: {$output->faultcode} <br/>";
echo "FaultString: {$output->faultstring} <br/>";
} else {
echo "<h2>Output: </h2><p>";
file_put_contents('dhl.xml', $output);
echo $output;
echo "</p/>";
}
Return: https://justpaste.it/52zqa (sorry too long)
The question is what do I get to get this xml?
Not returning the shipment number and returning the corresponding data
I think you are getting an WSDL because your URL is asking for it. Try removing the ?WSDL:
$url = 'https://wsbexpress.dhl.com:443/sndpt/expressRateBook';
References:
How to get the wsdl file from a webservice's URL
SOAP request returned wsdl instead of expected SOAP response

how can i use the function CREATE in soap webservice in Navision in PHP?

Here you can see documentation. It is in C# . I tried to make a working example using PHP. I managed to execute the Read & ReadMultiple functions in PHP. This is my try:
require ("./NTLMSoapClient.php");
$client = new NTLMSoapClient(null, array(
'cache_wsdl' => WSDL_CACHE_NONE,
'trace' => true,
'location' => "http://83.166.204.26:7147/TEST/WS/Harmont%20Blaine_TEST/Page/WebItem",
'uri' => "urn:microsoft-dynamics-schemas/page/webitem",
));
$client->user = "xxxxxx";
$client->password = "xxxxxxxxx";
try{
$resp = $client->Create(new SoapVar('555554', XSD_STRING, null, null, 'ns1:No' ));
echo "REQUEST:\n" . htmlentities($client->__getLastRequest()) . "\n";
}catch(SoapFault $sf){
//echo "REQUEST:\n" . htmlentities($client->__getLastRequest()) . "\n";
print '<pre>';
print_r($sf);
print '</pre>';
}
print '<pre>';var_dump($resp); print '</pre>';
It returns me NULL for some reason. Any idea why is not working?
Freddy Kristiansen did a wonderful series of blog posts with detailed explanation how to connect to Nav web services from different environments.
First part is here:
Connecting to NAV Web Services from …
The second part:
Connecting to NAV Web Services from PHP
Client can receive NULL response for several reasons. First of them - client application is unable to authenticate on the web service. This can happen if the server side uses SPNEGO protocol instead of NTLM. You need to set the key "ServicesUseNTLMAuthentication" in CustomSettings.config, as Freddy described in the first of his posts.
If you can read data from the service, but cannot create a record, this means that the request successfully passes authentication, and the problem is likely in the SOAP message format.
This is what Nav expects to receive in Create request
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Create xmlns="urn:microsoft-dynamics-schemas/page/customer">
<Customer>
<No>555554</No>
<Name>NewCustomer</Name>
</Customer>
</Create>
</soap:Body>
</soap:Envelope>
To achieve this result, you could replace standard HTTP stream wrapper with NTLMStream wrapper (see the post "Connecting to NAV web services from PHP" above.
Now, this is all you need to do to read a customer record:
$client = new NTLMSoapClient("http://192.168.0.101:7047/DynamicsNAV71/WS/".rawurlencode($company)."/Page/Customer");
$resp = $client -> Read(array('No' => '10000'));
Creating new records becomes much easier as well:
$client = new NTLMSoapClient("http://192.168.0.101:7047/DynamicsNAV71/WS/".rawurlencode($company)."/Page/Customer");
class CustomerWrapper
{
public $Customer;
}
$cw = new CustomerWrapper;
$cw -> Customer -> No = "555554";
$cw -> Customer -> Name = "NewCustomerName";
$cw -> Customer -> E_Mail = "john.doe#cronuscorp.net";
$resp = $client -> Create($customer);
THIS is the solution :
$resp = $client->Create(new SoapVar('5555195', XSD_STRING, null, null, 'ns1:WebItem' ));
I have to change the No to WebItem
see here:
<xsd:element name="Create">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="WebItem" type="tns:WebItem"/></xsd:sequence></xsd:complexType>
</xsd:element>

passing multiple WSDL header variables to SOAP server

I am using SOAP web services for the first time and i am having a problem in calling the SOAP server. I searched through WSDL SOAP request not i am not able to solve my problem. This is the snippet of my WSDL
<s:complexType name="VerHeader">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="HD1" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="HD2" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="HD3" type="s:string"/>
</s:sequence>
<s:anyAttribute/>
</s:complexType>
I have to send username, password and some ID in these HD1, HD2 and HD3 variables. I have also tried these links Passing a PHP array in a SOAP call and Sending a Soap Header with a WSDL Soap Request with PHP
Here is what i have tried but not working, every time i run my code it send failure message, can you figure it out what's wrong with my code or my logic?
$soap = new SoapClient("http://example.com/verifyrecord.asmx?WSDL");
$header = array('HD1'=>'000000023','HD2'=>'val2','HD3'=>'val2');
$header = new SoapHeader('http://www.example.com/', 'VerHeader ', $header);
$soap->__setSoapHeaders(array($header));
Solved the problem. I solved it not by using php functions but creating an xml file manually and sending it to the soap server. I've posted an example of my answer so that it might be helpful to others. Thanks all for the help.
// the xml to send
$xml = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<VerHeader xmlns="http://www.example.com/">
<HD1>000000000117</HD1>
<HD1>user</HD1>
<HD1>password</HD1>
</VerHeader>
</soap:Header>
<soap:Body>
<m:VerifyTransaction xmlns:m="http://www.example.com/">
<m:object1>45344</m:object1>
<m:object2>5545437</m:object2>
</m:VerifyTransaction>
</soap:Body>
</soap:Envelope>';
// build your http request
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Content-type: text/xml\r\n",
'validateRequest'=>false,
'content' => $xml,
'timeout' => 10,
),
));
// send it
echo $xmlstring = file_get_contents('http://example.com/VerifyThis/VerifyThis.asmx?wsdl', false, $context);
shouldn't this
new SoapHeader('http://www.example.com/', 'VerHeader ', $header);
be
new SoapHeader('http://www.example.com/verifyrecord', 'VerHeader ', $header);
try like this i did used this for my uk mail api .. and it worked
<?php
$LoginWebRequest = new stdClass();
$LoginWebRequest->Username = 'xxx cant show here xxx';
$LoginWebRequest->Password = 'xxx cant show here xxx';
//echo "<pre>"; print_r($LoginWebRequest); "</pre>"; exit;
$Login = new stdClass();
$Login->loginWebRequest = $LoginWebRequest;
//echo "<pre>"; print_r($Login); "</pre>"; exit;
$soapClient = new SoapClient('https://qa-api.ukmail.com/Services/UKMAuthenticationServices/UKMAuthenticationService.svc?wsdl');
$LoginResponse = $soapClient->Login($Login);
?>

How is PHP 5.3 SOAP request formed?

I am trying to write some code to talk to the SmarterMail API, but I can't seem to make PHP format the request properly. The [ugly] code I have so far is:
<?php
function array_to_params($in_arr) {
$out_arr = array();
foreach( $in_arr as $key => $value ) {
$out_arr[] = new SoapParam($value, $key);
}
return $out_arr;
}
echo "<pre>";
$soapClient = new SoapClient(
"http://mailserver.net/Services/svcDomainAdmin.asmx?WSDL",
array('trace' => true)
);
var_dump($soapClient->__getTypes());die();
$soap_user_params = array(
'blank' => 'blank', //if I don't have a dummy entry the first parameter doesn't show up.
'AuthUserName' => 'admin',
'AuthPassword' => 'derp'
);
$soap_user_params = array_to_params($soap_user_params);
$error = FALSE;
try {
$info = $soapClient->__soapCall("GetAllDomains", $soap_user_params);
// $info = $soapClient->GetAllDomains($soap_user_params); //same results
} catch (SoapFault $fault) {
$error = TRUE;
printf("Error %s: %s\n", $fault->faultcode, $fault->faultstring);
}
if( !$error ) {
var_dump($info);
echo "\nRequest: " . htmlentities($soapClient->__getLastRequest());
}
echo "</pre>";
?>
For reference, the WSDL for this function is:
<s:element name="GetAllDomains">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="AuthUserName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="AuthPassword" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
The example request given is:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetAllDomains xmlns="http://tempuri.org/">
<AuthUserName>string</AuthUserName>
<AuthPassword>string</AuthPassword>
</GetAllDomains>
</soap:Body>
</soap:Envelope>
But the request generated by my code is:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:GetAllDomains/>
<AuthUserName>admin</AuthUserName>
<AuthPassword>derp</AuthPassword>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
You can see that the username and password parameters are not contained within the GetAllDomains section for some reason. As well, in the code you can see that I have to pass a dummy parameter in first because whatever is first does not show up in the request. Also, I cannot simply pass in an associative array because the keys are not used as parameter names, it puts in 'param1' and 'param2' instead.
I should note that the server accepts the request and spits back a message about the auth failing. There is a built-in SOAP request tester on the server, and when the request fits the given example it works normally.
Everything I've looked up in the PHP docs and through Google seems to indicate that it should not be this difficult. :(
Any help is GREATLY appreciated.
note: I am running PHP 5.3.8 on Apache 2.2 on FreeBSD, built and installed via ports today.
post-answer-edit:
Thanks to Gian's answer below I've gotten this working and greatly simplified the code:
<?php
echo "<pre>";
$soapClient = new SoapClient( "http://mailserver.net/Services/svcDomainAdmin.asmx?WSDL", array( 'trace' => true ) );
$soap_user_params = array(
'AuthUserName' => 'admin',
'AuthPassword' => 'derp'
);
try {
$info = $soapClient->__soapCall("GetAllDomains", array( 'parameters' => $soap_user_params ) );
var_dump($info);
echo "\nRequest:\n" . htmlentities($soapClient->__getLastRequest());
} catch (SoapFault $fault) {
printf("Error %s: %s\n", $fault->faultcode, $fault->faultstring);
}
echo "</pre>";
My apologies for the mis-directed close. I misunderstood what you were trying to do at first.
Sifting through the soapCall documentation comments, there are a couple things I'd suggest trying. First off, this:
$soap_user_params = array(
'parameters' => array (
'AuthUserName' => 'admin',
'AuthPassword' => 'derp'
)
);
Apparently your parameters need to be an element in an associative array with the key 'parameters'. Weird, huh?
Failing that, you may need to nest this even deeper! The _ array entry does not appear to be documented anywhere obvious, but this seems to be something that the commenters on the PHP docs were suggesting. So maybe this:
$soap_user_params = array(
'parameters' => array (
'AuthUserName' => array('_' => 'admin'),
'AuthPassword' => array('_' => 'derp')
)
);

Categories