tuliovsmartins has asked for the wisdom of the Perl Monks concerning the following question:

Hello all, this is my first post in the pearl Monks and i really sorry if i did something whrong but i need help

IŽm trying to consume a webservice API from SwiftKanban on this address: https://www.digite.com/knowledge-base/swiftkanban/article/kanbancardservice-2/ and this is what i'm doing:

sub createCardOnProjectName { my ($username, $password, $projectName ) = @_; my $method = 'addCard'; my $soap_action = sub {return 'https://login.swift-kanban.com/axis +2/services/KanbanCardService?wsdl' . '/' . $method}; my $SoapClient = SOAP::Lite ->uri('https://login.swift-kanban.com/axis2/services/KanbanCardSer +vice?wsdl') ->proxy('https://login.swift-kanban.com/axis2/services/KanbanCardS +ervice') ->autotype(0) ->on_action( $soap_action ); my $Security = getHeader($SoapClient, $username, $password); my $projectId = returnProjectIdFromName($username, $password, $pro +jectName, $Security ); my $cardType = returnCardListFromProjectDetail($username, $passwor +d, $projectId, $Security ); #my $cardMetaData = returnCardMetaData ($username, $password, $car +dType, $Security ); #my $method_name = SOAP::Data->name($method)->attr({'xmlns' => $se +lf->xmlns()}); my $beamlineName = SOAP::Data->name('addCardDetails' => \SOAP::Dat +a->value( SOAP::Data->name("projectId")->value($projectId)->type("")->pr +efix('kan'), SOAP::Data->name("cardType")->value($cardType)->type("")->pref +ix('kan'), SOAP::Data->name("userLoginId")->value($username)->type("")->p +refix('kan'), SOAP::Data->name('fields' => \SOAP::Data->value( SOAP::Data->name('field')->value('teste de criacao')->type +("")->attr({"name" => "name"})->prefix('kan'), SOAP::Data->name('field')->value('M')->type("")->attr({"na +me" => "cardSize"})->prefix('kan'), SOAP::Data->name('field')->value('Expedite')->type("")->at +tr({"name" => "classOfService"})->prefix('kan'), SOAP::Data->name('field')->value('PM')->type("")->attr({"n +ame" => "Category"})->prefix('kan'), ), )->prefix('kan'), )->prefix('kan'), )->prefix('kan'); my $xml = $SoapClient->call($method, $Security, $beamlineName)->re +sult; return $xml; }

The code produces the xml:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/enve +lope/" xmlns:kan="http://kanbancard.webservices.kanban.app.digite.co +m/"> <soapenv:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004 +/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstan +d="1"> <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/ +wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="User +nameToken-31571602"> <wsse:Username>IntegrationUser_1078957</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/20 +04/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">005L8 +FM#</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> <soapenv:Body> <addCard xmlns="https://login.swift-kanban.com/axis2/services/ +KanbanCardService?wsdl"> <kan:addCardDetails> <kan:projectId>1</kan:projectId> <kan:cardType>KanbanIssue</kan:cardType> <kan:userLoginId>IntegrationUser_1078957</kan:userLogi +nId> <kan:fields> <kan:field name="name">teste de criacao</kan:f +ield> <kan:field name="cardSize">M</kan:field> <kan:field name="classOfService">Expedite</kan +:field> <kan:field name="Category">PM</kan:field> </kan:fields> </kan:addCardDetails> </addCard> </soapenv:Body> </soapenv:Envelope>

The SwiftKanban support ask me to send the xml without the tag: <addCard xmlns="https://login.swift-kanban.com/axis2/services/KanbanCardService?wsdl"> but i coudŽnt remove it

If someone can help-me iŽll apreciate

Tanks!

Replies are listed 'Best First'.
Re: Help with SOAP::Lite and SwiftKanban API
by poj (Abbot) on Sep 26, 2018 at 07:28 UTC

    Perhaps you can adapt this to exactly what you need

    #!perl use strict; use SOAP::Lite; my $uri = 'https://login.swift-kanban.com/axis2/services/KanbanCard +Service?wsdl'; my $proxy = 'https://login.swift-kanban.com/axis2/services/KanbanCard +Service'; my $client = SOAP::Lite->uri($uri) ->proxy("loopback://"); $client->autotype(0); $client->outputxml(1); $client->readable(1); $client->ns($uri,'kan'); $client->envprefix('soapenv'); my %value = ( 'name' => 'teste de criacno', 'cardSize' => 'M', 'classOfService' => 'Expedite' ); my @fields; for my $field (sort keys %value){ push @fields,SOAP::Data->name( "field"=> $value{$field} ) ->attr( {'name'=>$field} ) ->prefix('kan'); }; my %data = ( projectId => 'PROJECTID', cardType => 'CARDTYPE', userLoginId => 'USERLOGINID', fields => \@fields, ); my @data; my @keys = qw(projectId cardType userLoginId fields); for (@keys){ push @data,SOAP::Data->name($_ => $data{$_})->prefix('kan') } my $response = $client->call('addCardDetails',@data); print $response;
    poj

      Great Man,

      This solved my issue so easy...

      After spent 2 days looking for the answer iŽm very thankfull to you poj

      Regards!