ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Consuming a web service

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Re: Consuming a web service

    Here is the WSDL:
    Code:
    <web:GetAllAccountInfoAcctNbr>6111027582601</web:GetAllAccountInfoAcctNbr>
    And here is the response:
    Code:
    <agentIdentities>
    <userId>agent2.geisler@dev.cox.net</userId>
    <username>agent2.geisler</username>
    </agentIdentities>
    <agentIdentities>
    <userId>agent3.geisler@dev.cox.net</userId>
    <username>agent3.geisler</username>
    </agentIdentities>
    I am trying to extract the username and userID.
    Do I need to do something like this?

    Code:
    <?php
        error_reporting(E_ALL);
        $GetUserName = new SoapClient("http://idm.east.dev.cox.net/idmwebservices/CoxIdentityServices?wsdl");
        $account = array("GetAllAccountInfoAcctNbr" => "6111027582601");
    
        $username = $GetUserName->username($account);
        $userId = $GetUserName->userId($account);
        ?>

    Comment


    • #17
      Re: Consuming a web service

      Well you haven't actually given me the wsdl (that's the stuff in the file at http://idm.east.dev.cox.net/idmwebse...yServices?wsdl) you gave part of the request envelope but ...

      What you have look about right - I'm still fighting may way through this stuff myself.

      If I was you I would do a var_dump of the returned object and see how it is structured. Without looking it up I don't know - since agentIdentities appears to be a repeating element, it is likely that you may have to retrieve that from the returned object and _then_ access the pieces you want - a var_dump will show you what you need.

      Comment


      • #18
        Re: Consuming a web service

        I am afraid to say that I do not know what a var_dump is.

        Comment


        • #19
          Re: Consuming a web service

          Any idea what this means?

          Fatal error: Uncaught SoapFault exception: [Client] Function ("username") is not a valid method for this service in /www/zendcore/htdocs/cox/GetAccountInfo.php:11 Stack trace: #0 [internal function]: SoapClient->__call('username', Array) #1 /www/zendcore/htdocs/cox/GetAccountInfo.php(11): SoapClient->username(Array) #2 {main} thrown in /www/zendcore/htdocs/cox/GetAccountInfo.php on line 11

          Here is the script:

          Code:
          <?php
          
          	ini_set('display_errors','1');
          	error_reporting (E_ALL);
          
              $GetUserName = new SoapClient("http://idm.east.dev.cox.net/idmwebservices/CoxIdentityServices?wsdl");
          
              $account = array("GetAllAccountInfoAcctNbr" => "6111027582601");
          
              $username_r = $GetUserName->username($account);  <= this is line 11
              $userId_r   = $GetUserName->userId($account);
          
              echo "<br>Account: $account";
              echo "<br>User Name: $username_r";
              echo "<br>User ID: $userId_r";
          
          	var_dump($account);
          
          
           ?>

          Comment


          • #20
            Re: Consuming a web service

            As I noted before - I think that you may need to request agentIdentities e.g. $userDetail = $GetUserName->agentIdentities($account);

            You didn't tell us what the var_dump() showed you so it is hard to be sure.

            Jon P.

            Comment


            • #21
              Re: Consuming a web service

              I added the var_dump but I dont think the script is getting that far. I get a message that "method not valid for service".

              Fatal error: Uncaught SoapFault exception: [Client] Function ("agentIdentities") is not a valid method for this service in /www/zendcore/htdocs/cox/GetAccountInfo.php:11 Stack trace: #0 [internal function]: SoapClient->__call('agentIdentities', Array) #1 /www/zendcore/htdocs/cox/GetAccountInfo.php(11): SoapClient->agentIdentities(Array) #2 {main} thrown in /www/zendcore/htdocs/cox/GetAccountInfo.php on line 11

              Code:
              <?php
              
              	ini_set('display_errors','1');
              	error_reporting (E_ALL);
              
                  $GetUserName = new SoapClient("http://idm.east.dev.cox.net/idmwebservices/CoxIdentityServices?wsdl");
              
                  $account = array("GetAllAccountInfoAcctNbr" => "6111027582601");
              
                  $userDetail = $GetUserName->agentIdentities($account);
              
               	var_dump($userDetail);
              
               ?>

              Comment


              • #22
                Re: Consuming a web service

                Sorry - but without the complete wsdl there's not much more I can suggest.

                Do you have examples of this being used in other languages? That would help.

                Try a var_dump on $GetUsername immediatly after instantiating it - and comment out the call that cuses the exception so you'll see the output.

                Comment


                • #23
                  Re: Consuming a web service

                  Here is the complete WSDL. I will try your suggestion now.

                  Code:
                  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.idm.cox.com/">
                  <soapenv:Body>
                  <web:GetAllAccountInfoAcctNbr>6111027582601</web:GetAllAccountInfoAcctNbr> 
                  <web:GetAllAccountInfoGetIcomsCpni>false</web:GetAllAccountInfoGetIcomsCpni> 
                  </soapenv:Body>
                  </soapenv:Envelope>

                  Comment


                  • #24
                    Re: Consuming a web service

                    results of var_dump

                    object(SoapClient)#1 (2) { ["_soap_version"]=> int(1) ["sdl"]=> resource(2) of type (Unknown) }

                    Code:
                    <?php
                    
                    	ini_set('display_errors','1');
                    	error_reporting (E_ALL);
                    
                        $GetUserName = new SoapClient("http://idm.east.dev.cox.net/idmwebservices/CoxIdentityServices?wsdl");
                    
                        //$account = array("GetAllAccountInfoAcctNbr" => "6111027582601");
                    
                        //$userDetail = $GetUserName->agentIdentities($account);
                    
                     	var_dump($GetUserName);
                    
                     ?>

                    Comment


                    • #25
                      Re: Consuming a web service

                      That's not the wsdl - it is the request envelope that gets generated from the wsdl definition.

                      It is the wsdl that defines what this envelope should look like and what the response will look like.

                      Since it is the _complete_ response packet we need to study we need to see the wdsl.

                      Comment


                      • #26
                        Re: Consuming a web service

                        Better - but still need wsdl for anything meaningful mere.

                        Comment


                        • #27
                          Re: Consuming a web service

                          Oh. I fumbled around in SoapUI and found the WSDL listed under Interface Summary. It is a bit long, so I am adding it to the post as an attachment. By the way, I really appreciate the help!
                          Attached Files

                          Comment


                          • #28
                            Re: Consuming a web service

                            Hadn't seen this one before - the __getFunctions() method - try it - it will show you what methods are available from the client.

                            var_dump($YourClientNameHere->__getFunctions());

                            Comment


                            • #29
                              Re: Consuming a web service

                              By client name I assume you mean $GetUserName. I did that I did get what looks like a dump alright. Hard to decipher since I do not know what I am looking for.

                              Comment


                              • #30
                                Re: Consuming a web service

                                Originally posted by tdavis View Post
                                By client name I assume you mean $GetUserName. I did that I did get what looks like a dump alright. Hard to decipher since I do not know what I am looking for.
                                How about posting it! I can't get the wsdl to load in SoapUI and although I love the tool its error reporting sucks.

                                Comment

                                Working...
                                X