#!/usr/bin/perl use SOAP::Lite; # SOAP API use HTTP::Cookies; use XML::DOM; $uri = 'urn:PDBjSOAPServiceX'; $url = 'http://pdbjs8.protein.osaka-u.ac.jp/soap/servlet/messagerouter'; $dbURL = "http://pdbjs8.protein.osaka-u.ac.jp/tamino/pdbMLplus"; $colName = "pdbMLplus_Collection"; if ($ARGV[0] eq "" || lc($ARGV[0]) eq "-h" || lc($ARGV[0]) eq "-help") { printf("sample2.pl [pdbid]\n"); printf(" call method : \n"); printf(" void connect(string dbURL)\n"); printf(" void setaccesslocation(string collectionName)\n"); printf(" org.w3c.dom.Element xquery(string xpath, string result_num)\n"); printf(" void disconnect()\n"); printf(" uri : \n"); printf(" $uri\n"); printf(" url : \n"); printf(" $url\n"); exit; } my $pdbid = $ARGV[0]; my $xpath = "/datablock[\@datablockName='" . uc($pdbid) . "-noatom']" ; ### Result Num ### $num = 1; ### Time out (second) ### $tm = 5 * 60; $method1 = 'connect'; $method2 = 'setaccesslocation'; $method3 = 'xquery'; $method5 = 'disconnect'; # encodingStyle $enc1 = 'http://schemas.xmlsoap.org/soap/encoding/'; $enc2 = 'http://xml.apache.org/xml-soap/literalxml'; # set uri,endpoint and load module my $service = SOAP::Lite -> uri($uri) -> proxy($url, cookie_jar => HTTP::Cookies->new(ignore_discard => 1), timeout => $tm); $service -> $method1($dbURL); ## connect $service -> $method2($colName); ## setaccesslocation $res = $service ->outputxml(true); my $parser = new XML::DOM::Parser(ErrorContext=>3); # call method(xquery) and String->Element $doc1 = $parser->parse($service->call(SOAP::Data->name($method3) ->attr({xmlns => $uri, 'SOAP-ENV:encodingStyle' => $enc2 }) =>SOAP::Data ->type(string => $xpath) =>SOAP::Data ->type(string => $num) ->encodingStyle($enc1))); @top_node_list1 = &getElementList($doc1); # print result foreach $node (@top_node_list1) { print $node->toString(),"\n"; } $service -> $method5(); ## disconnect sub getElementList { my ($doc) = @_; my @ret_list = (); if ($doc ne undef) { my $node = $doc->getElementsByTagName("response")->item(0); if ($node ne undef) { my @childs = $node->getChildNodes(); foreach $child (@childs) { push @ret_list, $child; } } } return @ret_list; }