0

I'm working on a project where I need to pass parameters to a .NET web service. Below is what the .NET SOAP request structure looks like.

<soap:Body>
<ListRequest xmlns="My.API.1.0">
      <ID>guid</ID>
      <Parameters>
        <Values xmlns="api.test">
          <fv ID="string">
            <Value />
            <ValueTranslation>string</ValueTranslation>
          </fv>
          <fv ID="string">
            <Value />
            <ValueTranslation>string</ValueTranslation>
          </fv>
        </Values>
      </Parameters>      
</ListRequest>
</soap:Body>

Below is part of the PHP code.

$params=array('ID'=> $listID,
              'Parameters' => 
                array(
                   array('ID' => 'ROOM', 'ValueTranslation' => '99999')));                    

        $result=$soapClient->ListRequest($params);

Whenever I make the call without the parameter the request works and gets the results back to the php page. But when I introduce the parameters, I get "the function GETLIST expects parameter 'ROOM', which was not supplied" error. I've a feeling the the issue is the way I'm mapping the Parameter structure but I can't figure out how to map the SOAP xml above to a php code.

Thank you all for your help!

1 Answer 1

3

I don't think that you can specify parameters for a soap request using assoc arrays. Try using objects instead, it have worked for me in the past

$params = new stdClass();
$params->ID = $listId;

$params->Parameters = new stdClass();

$params->Parameters->Values = new stdClass();
$params->Parameters->Values->fv = array();

//Child of "Parameters"
$p = new stdClass();
$p->ID = 'ROOM';
$p->ValueTranslation = '99999';

$params->Parameters->Values->fv[] = $p;

$soap->ListRequest($params);

Another solution is to use an XML DOM and handle the creation of the XML data yourself (Then simply pass it as string to the function you want to call in SOAP)

Furthermore the datastructure that you make with the assoc array does not match the structure it should be.. (take a good look at the XML you are posting and you will see what you are missing)

Edit: Think i made something that should reflect your schema now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.