how to assign attributes to paramater in php for nusoap client

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johnners
    New Member
    • Jun 2007
    • 2

    #1

    how to assign attributes to paramater in php for nusoap client

    Hi all

    I'm having trouble assigning an attribute to a namespace using nusoap/php when creating a new soapclient. I can get the soapclient to assign the parameters correctly but can't assign an attribute to any namespaces. The code below is from the actual soap request and i need to assign the 'ApplicantID' from the soapclient to the Applicant parameter for each new applicant, then have nested arrays within various arrays.

    [CODE=xml]<Applicant ApplicantID="1" >
    <Title>Miss</Title>
    <Forename>Tessa </Forename>
    <Secondname>Jan e</Secondname>
    <Surname>Smit h</Surname>
    <DOB>1966-12-29</DOB>
    <TelephoneHome> 01942408669</TelephoneHome>
    <TelephoneWork> 01942724915</TelephoneWork>
    </Applicant>[/CODE]

    I've set up all the arrays as follows, but was wondering how to assign the 'ApplicantID' to the 'Applicant' array in the soapclient.

    [PHP]$header = array('userId' => 'Ivuser', 'password' => 'Ivpa55word');
    $loandetail = array('Loan' => '5000', 'Term' => '24');
    $Applicant =
    $result = $client->call('sendv1 ', array('header' => $header), array('loandeta il' => $loandetail));[/PHP]

    i'm a total nusoap novice so sorry if i haven't given enough information. Your help would be much appreciated.
    Last edited by pbmods; Jun 20 '07, 02:35 PM. Reason: Changed CODE language. Thanks for using CODE tags!
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, johnners. Welcome to TSDN!

    It sounds like you're looking for an XML parser. PHP's got a couple of those....

    Comment

    • johnners
      New Member
      • Jun 2007
      • 2

      #3
      thanks for the reply - we're using a shared windows server which is having a few problems with .net applications and ssl certificates, hence we decided to re-write the application using php to access a webservice using a soap client. However we cannot have access to the php.ini or full root of the server to make any changes to the configuration of php. Using php4 so we thought we'd give nusoap a go to create the soap client. Just need to know how to code the array for the 'Applicant' in the soap client as the namespace has the 'ApplicantID' attribute. Having trouble getting the soapclient to pass on the 'ApplicantID' as part of the namespace.

      Not sure if i'm explaining it very clearly!

      Comment

      • omniasoft
        New Member
        • Jul 2007
        • 1

        #4
        I too am needing to know how to set a node attribute. I need to set an attribute to false to indicate a testing environment versus a live environment, and cannot test the XML call without that attribute which is required by the webservice server...

        Anyone? Anyone? Bueller?

        AG


        Originally posted by johnners
        Hi all

        I'm having trouble assigning an attribute to a namespace using nusoap/php when creating a new soapclient. I can get the soapclient to assign the parameters correctly but can't assign an attribute to any namespaces. The code below is from the actual soap request and i need to assign the 'ApplicantID' from the soapclient to the Applicant parameter for each new applicant, then have nested arrays within various arrays.

        [CODE=xml]<Applicant ApplicantID="1" >
        <Title>Miss</Title>
        <Forename>Tessa </Forename>
        <Secondname>Jan e</Secondname>
        <Surname>Smit h</Surname>
        <DOB>1966-12-29</DOB>
        <TelephoneHome> 01942408669</TelephoneHome>
        <TelephoneWork> 01942724915</TelephoneWork>
        </Applicant>[/CODE]

        I've set up all the arrays as follows, but was wondering how to assign the 'ApplicantID' to the 'Applicant' array in the soapclient.

        [PHP]$header = array('userId' => 'Ivuser', 'password' => 'Ivpa55word');
        $loandetail = array('Loan' => '5000', 'Term' => '24');
        $Applicant =
        $result = $client->call('sendv1 ', array('header' => $header), array('loandeta il' => $loandetail));[/PHP]

        i'm a total nusoap novice so sorry if i haven't given enough information. Your help would be much appreciated.

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          I don't generally use XML parsers to generate XML, to be honest. What I do is create an XML template and then create tags where I'd want stuff to go.

          [code=xml]
          <Applicant ApplicantID="[::ApplicantID::]">
          <Title>[::Title::]</Title>
          <Forename>[::Forename::]</Forename>
          <Secondname>[::Secondname::]</Secondname>
          <Surname>[::Surname::]</Surname>
          <DOB>[::DOB::]</DOB>
          <TelephoneHom e>[::TelephoneHome ::]</TelephoneHome>
          <TelephoneWor k>[::TelephoneWork ::]</TelephoneWork>
          </Applicant>
          [/code]

          Then load up your template, create an array of content:
          [code=php]
          $content = array(
          '[::ApplicantID::]' => $applicantID,
          '[::Title::]' => $title,
          .
          .
          .
          );
          [/code]

          And then run a fancy str_replace():
          [code=php]
          $xml = str_replace(arr ay_keys($conten t), array_values($c ontent), $template);
          [/code]

          Comment

          Working...