Let's look at the IBM problem.

IBM was one of the business I tested, and it worked. Actually one of the business came back under IBM was IBM Japan, and I got some wide charatcters.

I cannot cut and paste my testing result now, as I am behind firewall, but I definitely will update this post tonight. (I can enhance the code to work with firewall, but ...)

My guess is that, when you only got one business back in the SOAP reply, XML::Simple does not parse it into an array ref, as it does when multiple business were sent back, and I missed that. So I probably should do a ref() first.

However you should get the same SOAP reply as I did, when we both enquery IBM. This puzzles me a lot.

Here is the updated code, but the enhancement is untested, which I do tonight back home.

use Socket; use IO::Select; use XML::Simple; use Data::Dumper; use strict; use warnings; while (1) { print "Business: "; my $business = <>; chomp($business); if ($business) { my $businesses = find($business); display($businesses); } else { last; } } sub display { my $businesses = shift; foreach my $key (keys(%$businesses)) { print "-$key\n"; print "---$businesses->{$key}\n" if(defined($businesses->{$key +})); } print "=========================================\n"; } sub find { my $name = shift; socket(UDDI, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die " +socket: $!"; connect(UDDI, sockaddr_in(80, inet_aton("www-3.ibm.com"))) || die +"connect: $!"; my $envelope = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.or +g/soap/envelope/\">" . "<SOAP-ENV:Body>" . "<find_business generic=\"2.0\" maxRows=\"100\" xmlns= +\"urn:uddi-org:api_v2\">" . "<name>" . $name . "</name>" . "</find_business>" . "</SOAP-ENV:Body>" . "</SOAP-ENV:Envelope>"; my $msg = "POST /services/uddi/inquiryapi HTTP/1.1\r\n" . "Content-Type: text/xml; charset=\"utf-8\"\r\n" . "Content-Length: " . length($envelope) . "\r\n" . "SOAPAction: \"\"\r\n" . "Cache-Control: no-cache\r\n" . "Pragma: no-cache\r\n" . "User-Agent: Peter Script\r\n" . "Host: www-3.ibm.com\r\n" . "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n" + . "Connection: keep-alive\r\n" . "\r\n" . $envelope; syswrite(UDDI, $msg); my $res = ""; my $sel = new IO::Select(*UDDI); while ($sel->can_read) { my $chunk; sysread(UDDI, $chunk, 100000); if (!length($chunk)) { last; } else { $res .= $chunk; } } close(UDDI); $res =~ m/.*?\r\n\r\n(.*)/; $res = $1; my $hash = XMLin($res); my $result = {}; if (ref($hash->{"SOAP:Body"}->{"businessList"}->{"businessInfos"}- +>{"businessInfo"}) eq "ARRAY") { foreach my $business (@{$hash->{"SOAP:Body"}->{"businessList"} +->{"businessInfos"}->{"businessInfo"}}) { $result->{$business->{"name"}->{"content"}} = $business->{ +"description"}->{"content"}; } } else { #I will add later, as I cannot test now, and I don't want to p +ost untested code in this case } return $result; }

In reply to Re: Re: UDDI busness query by pg
in thread UDDI business query by pg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.