in reply to Re: Displaying SOAP Request and Response
in thread Displaying SOAP Request and Response

Poj You have me very close to figuring this out. I am uncertain that you are a Cisco Voice guy, so you may not have a solution to my current issues, but I will post my updated code below. I do get errors printed out to the file and the errors seem to come from Cisco Communications manager. What you could help me with is being able to set up Children for the "SelectItems" element. As you can see my updated code, I did this is a very naive way, I think.

#!/usr/bin/perl my $cucm_ip = "10.74.13.228"; my $user_axl = "user"; my $password_axl = "password"; my $dev ="SEPE8BA70FB8CB5"; ###################################################################### +######################### $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; use SOAP::Lite; BEGIN { sub SOAP::Transport::HTTP::Client::get_basic_credentials { return ($user_axl => $password_axl) } } my $CUCM = SOAP::Lite ->uri("http://schemas.cisco.com/ast/soap/action/#RisPort# +selectCmDevice") #->uri("http://schemas.cisco.com/ast/soap/") ->proxy("https://$cucm_ip:8443/realtimeservice/services/Ris +Port"); ###Maybe ?wsdl"); #->proxy("loopback://"); $CUCM->outputxml(1); $CUCM->readable(1); #$CUCM->envprefix('soapenv'); #$CUCM->ns($uri,'soap'); $CUCM->autotype(0); print "The Device $dev\n\n\n"; #####i################################################################ +############################# my %select =( "MaxReturnedDevices" => 200, "DeviceClass" => "Any", "Model" => 255, "Status" => 'Any', "NodeName" => '', "SelectBy" => 'Name', "SelectItems" => "<item><Item>$dev</Item></item>", "Protocol" => 'Any', "DownloadStatus" => 'Any' ); ################################################################# my $state = SOAP::Data->name('StateInfo',''); my $data = SOAP::Data->name('CmSelectionCriteria' , => \%select); my $elem = SOAP::Data->type('data' => $data); my $response = $CUCM->selectCmDevice($state,$elem); ##my $status=$response->valueof('//return/row/Status'); ##print "status is : $status\n\n"; open OUT,'>','soap.xml' or die "$!"; print OUT $response; close OUT;

Also, I was building an envelope for a different version of CUCM than I have, please see below for the right format. I see that the elements have attributes, do I need to include those in my message? If so, how is this achieved? I know for sure there should be an attribute to the CmSelection Criteria, this is a session Id. Can you please help me include that in my code?

<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <ns1:SelectCmDevice soapenv:encodingStyle="http://schemas.xmlsoap.org +/soap/encoding/" xmlns:ns1="http://schemas.cisco.com/ast/soap/"> <StateInfo xsi:type="xsd:string"/> <CmSelectionCriteria href="#id0"/> </ns1:SelectCmDevice> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:CmSelectionCriteria" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://schemas.cisco.com/ast/soap/"> <MaxReturnedDevices xsi:type="xsd:unsignedInt">200</MaxReturnedDevice +s> <Class xsi:type="xsd:string">Any</Class> <Model xsi:type="xsd:unsignedInt">255</Model> <Status xsi:type="xsd:string">Registered</Status> <NodeName xsi:type="xsd:string" xsi:nil="true"/> <SelectBy xsi:type="xsd:string">Name</SelectBy> <SelectItems soapenc:arrayType="ns2:SelectItem[1]" xsi:type="soapenc: +Array"> <item href="#id1"/> </SelectItems> </multiRef> <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:SelectItem" xmlns:ns3="http://schemas.cisco.com/ast/soap +/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <Item xsi:type="xsd:string">*</Item> </multiRef> </soapenv:Body> </soapenv:Envelope>

Replies are listed 'Best First'.
Re^3: Displaying SOAP Request and Response
by poj (Abbot) on Mar 09, 2017 at 08:20 UTC
    set up Children for the "SelectItems" element

    I showed that here

    for (6963..6965){ push @items,SOAP::Data->name( "item"=> \SOAP::Data->value( SOAP::Data->name("Item"=> $_) )); }; . . "SelectItems" => $items,

    Just change the 6963..6965 to an array @device of your own device numbers. If they are in a file then use something like this perhaps

    open IN,'<', $path_file or die "Could not open $path_file : $!"; my @device = (); while (<IN>){ if (m/(SEP[0-9A-Z]+)/i){ push @device,$1; } } close IN;

    Note you have a error (extra comma) in this line

    my $data  = SOAP::Data->name('CmSelectionCriteria' ,  => \%select);
    poj

      Thank you for the clarification. I corrected my code and the result is more like what I need. The session Id is still missing from my envelope. Apparently it belongs in the header, like so:

      <soap:Header> <tns:AstHeader id="id1"> <SessionId xsi:type="xsd:string">SessionId</SessionId> </tns:AstHeader> </soap:Header>

      I know that my current code does not specify anything in the header. Doing some research I see that instead of SOAP::Data, I would use SOAP::Header right? BUt how exactly do I do this? Thanks.

        Try

        my $header = SOAP::Header->name("tns:AstHeader" => { SessionId => "SessionID" } ); $header->attr({ id => "id1" } ); my $response = $CUCM->selectCmDevice($header,..);
        poj

      Also, my envelope always gets constructed in different order?