Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:52:38+00:00 2026-05-27T04:52:38+00:00

I am trying to write some code to talk to the SmarterMail API, but

  • 0

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>";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:52:39+00:00Added an answer on May 27, 2026 at 4:52 am

    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')
        )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write some code to return an array in C#, but
I'm trying to write some code that uses Numpy. However, I can't import it:
I'm trying to write some code against libnotify, but the documentation for perl with
I'm trying to write some code to find a specific XmlNode object based on
I'm trying to write some code to work with an htdigest password file. The
I was trying to write some code that would check if an item has
I'm trying to write some code using pure SQL using ASP.NET MVC. I assume
I'm trying to write some code to Hide columns if the first 3 characters
I'm trying to write some code to remove the first N characters in a
I am trying to write some code that that will draw the line which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.