Guest User

Untitled

a guest
Mar 30th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.52 KB | None | 0 0
  1. SOAP::Serializer::envelope: Client Denied access to method (AnalyzeDocument) in class (main) at /usr/share/perl5/site_perl/SOAP/Lite.pm line 2806
  2.  
  3. # TODO - sort this mess out:
  4. # The task is to test whether the class in question has already been loaded.
  5. #
  6. # SOAP::Lite 0.60:
  7. # unless (defined %{"${class}::"}) {
  8. # Patch to SOAP::Lite 0.60:
  9. # The following patch does not work for packages defined within a BEGIN block
  10. # unless (exists($INC{join '/', split /::/, $class.'.pm'})) {
  11. # Combination of 0.60 and patch did not work reliably, either.
  12. #
  13. # Now we do the following: Check whether the class is main (always loaded)
  14. # or the class implements the method in question
  15. # or the package exists as file in %INC.
  16. #
  17. # This is still sort of a hack - but I don't know anything better
  18. # If you have some idea, please help me out...
  19. #
  20. unless (($class eq 'main') || $class->can($method_name)
  21. || exists($INC{join '/', split /::/, $class . '.pm'})) {
  22.  
  23. # allow all for static and only specified path for dynamic bindings
  24. local @INC = (($static ? @INC : ()), grep {!ref && m![/\.]!} $self->dispatch_to());
  25. eval 'local $^W; ' . "require $class";
  26. die "Failed to access class ($class): $@" if $@;
  27. $self->dispatched($class) unless $static;
  28. }
  29.  
  30. die "Denied access to method ($method_name) in class ($class)"
  31. unless $static || grep {/^$class$/} $self->dispatched;
  32.  
  33. return ($class, $method_uri, $method_name);
  34. }
  35.  
  36. vi /etc/apache2/sites-available/default
  37.  
  38. <Location /SOAP/>
  39. SetHandler perl-script
  40. PerlHandler Apache::SOAP
  41. PerlSetVar dispatch_to '/usr/share/perl5/'
  42. </Location
  43.  
  44. package HelloWorld;
  45.  
  46. use strict;
  47. use warnings;
  48.  
  49. sub sayHello {
  50. return "Hello @_n";
  51. }
  52.  
  53. 1;
  54.  
  55. use SOAP::Lite +trace;
  56.  
  57. use strict; use warnings;
  58.  
  59. my $client = SOAP::Lite->new;
  60. my $ua = $client->schema->useragent;
  61. $ua->agent("Fubar! 0.1");
  62.  
  63. my $response = $client
  64. # WSDL url
  65. ->service("http://example.com/HelloWorld.xml") // this current wsdl
  66.  
  67. # method from SOAP server Module
  68. ->sayHello("foo", "bar");
  69.  
  70. print $response;
  71.  
  72. <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  73. xmlns:s="http://www.w3.org/2001/XMLSchema"
  74. xmlns:s0="urn:HelloWorld"
  75. targetNamespace="urn:HelloWorld"
  76. xmlns="http://schemas.xmlsoap.org/wsdl/">
  77. <types>
  78. <s:schema targetNamespace="urn:HelloWorld">
  79. </s:schema>
  80. </types>
  81. <message name="sayHello">
  82. <part name="name" type="s:string" />
  83. <part name="givenName" type="s:string" />
  84. </message>
  85. <message name="sayHelloResponse">
  86. <part name="sayHelloResult" type="s:string" />
  87. </message>
  88.  
  89. <portType name="Service1Soap">
  90. <operation name="sayHello">
  91. <input message="s0:sayHello" />
  92. <output message="s0:sayHelloResponse" />
  93. </operation>
  94. </portType>
  95.  
  96. <binding name="Service1Soap" type="s0:Service1Soap">
  97. <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
  98. style="rpc" />
  99. <operation name="sayHello">
  100. <soap:operation soapAction="urn:HelloWorld#sayHello"/>
  101. <input>
  102. <soap:body use="encoded"
  103. encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  104. </input>
  105. <output>
  106. <soap:body use="encoded"
  107. encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  108. </output>
  109. </operation>
  110. </binding>
  111. <service name="HelloWorld">
  112. <port name="HelloWorldSoap" binding="s0:Service1Soap">
  113. <soap:address location="http://localhost:80/SOAP/" />
  114. </port>
  115. </service>
  116. </definitions>
  117.  
  118. **use strict;
  119. use warnings;
  120. use LWP::Protocol::https;
  121. use SOAP::Lite;
  122.  
  123. # Set SOAP username
  124. my $USER = "user";
  125.  
  126. # Set SOAP password
  127. my $PASSWORD = "password";
  128.  
  129. # Set SOAP API URL
  130. my $SERVICE_LOC = 'https://localhost:2443';
  131.  
  132. # XML namespace
  133. my $SERVICE_NS = 'http://name.space.domain/widget';
  134. my $URI = $SERVICE_NS;
  135.  
  136. my $OUTPUT_XML = 'true';
  137.  
  138. # we use this lat
  139. # The username and password are set by overriding the
  140. # SOAP::Transport::HTTP::Client::get_basic_credentials method
  141. #### Authentication
  142.  
  143. sub SOAP::Transport::HTTP::Client::get_basic_credentials {
  144. return $USER => $PASSWORD;
  145. }
  146.  
  147.  
  148. #### prototypes
  149.  
  150. sub method1;
  151. sub method2;
  152.  
  153. #### CONNECT TO SERVICE
  154.  
  155. my $Service = SOAP::Lite-> proxy ($SERVICE_LOC);
  156.  
  157. $Service->outputxml($OUTPUT_XML);
  158.  
  159.  
  160. #### Invoking Calls
  161.  
  162. print "nHey does SOAP work?n";
  163.  
  164. #### method1 Test
  165.  
  166. print "==> Invoking method1";
  167. my $result1 = method1($Service);
  168. if($OUTPUT_XML eq 'true'){
  169. print $result1;
  170. } else {
  171. if($result1){
  172. for my $t ($result1->valueof('//tag/subtag')) {
  173. print $t->{value1} . " - " . $t->{value2} . "n";
  174. }
  175. } else {
  176. print "no SOAP for you";
  177. }
  178. }
  179.  
  180. #### method2 Test
  181. my %DataStructure1 = (
  182. 'data1' => 'John Doe',
  183. 'data2' => '1234',
  184. );
  185. my %DataStructure2 = (
  186. 'data1' => 'Jane Doe',
  187. 'data2' => '4321',
  188. );
  189. my $result2 = method2($Service, %DataStructure1, %DataStructure2);
  190. if($OUTPUT_XML eq 'true'){
  191. print $result2;
  192. } else {
  193. if($result2){
  194. for my $t ($result2->valueof('//tag/subtag')) {
  195. print " " . $t->{value1} . " - " . $t->{value2} . " - " .
  196. $t->{subsubtag}{value3} . "n";
  197. }
  198. } else {
  199. print "no SOAP for you";
  200. }
  201. }
  202.  
  203.  
  204.  
  205.  
  206. #### Accessing Functions
  207.  
  208. sub method1{
  209. my $SOAP = shift;
  210. print "n==> Invoking call method1n";
  211.  
  212. my $URIs;
  213. my $SOM = $SOAP->method1('');
  214.  
  215. if($SOM){
  216. if($OUTPUT_XML eq 'true'){
  217. return $SOM;
  218. }elsif($SOM->fault) {
  219. die $SOM->faultstring;
  220. }else{
  221. return $SOM;
  222. }
  223. }
  224.  
  225. return 0;
  226. }
  227.  
  228. sub method2{
  229. my $Service = $_[0];
  230. my $DataStructure1 = $_[1];
  231. my $DataStructure2 = $_[2];
  232. print "n==> Invoking call method2n";
  233. my $Location = 'loc';
  234.  
  235. my $Structure1 = SOAP::Data->name('structure1')->value([
  236. SOAP::Data->name('data1')->value($DataStructure1->{'data1'}),
  237. SOAP::Data->name('data2')->value($DataStructure1->{'data2'}),
  238. ]);
  239.  
  240. my $Structure2 = SOAP::Data->name('structure2')->value([
  241. SOAP::Data->name('data1')->value($DataStructure2->{'data1'}),
  242. SOAP::Data->name('data2')->value($DataStructure2->{'data2'}),
  243. ]);
  244.  
  245. my $Meth = SOAP::Data->name('method2')->uri($SERVICE_NS);
  246.  
  247. my $SOM = $Service->call($Meth, $SERVICE_NS, $Location);
  248.  
  249. if($SOM){
  250. if($OUTPUT_XML eq 'true'){
  251. return $SOM;
  252. }elsif($SOM->fault) {
  253. die $SOM->faultstring;
  254. }else{
  255. return $SOM;
  256. }
  257. }
  258.  
  259. return 0;
  260. }**
Add Comment
Please, Sign In to add comment