php-general Digest 7 Jun 2008 09:14:57 -0000 Issue 5501

Topics (messages 275107 through 275111):

WSDL/SOAP/PHP5
        275107 by: Dan Joseph
        275108 by: Nathan Nobbe
        275109 by: Eric Butera

Re: Updating inherited attributes without __construct()
        275110 by: Nathan Nobbe

Re: spaces - not sure if this is a preg_match issue or a regexp issue
        275111 by: Runar Olsen

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi Everyone,

I'm struggling with a WSDL trying to make it work right.  I don't even know
what to really ask.

Basically I've created a WSDL and made a web service in PHP5.  It doesn't
seem to validate properly when a .NET client tries to hit

Is there something that can be used to generate the WSDL?  Should I just
abandon PHP5's SOAP and use NuSOAP?

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."

--- End Message ---
--- Begin Message ---
On Fri, Jun 6, 2008 at 2:53 PM, Dan Joseph <[EMAIL PROTECTED]> wrote:

> Hi Everyone,
>
> I'm struggling with a WSDL trying to make it work right.  I don't even know
> what to really ask.
>
> Basically I've created a WSDL and made a web service in PHP5.  It doesn't
> seem to validate properly when a .NET client tries to hit


have you tried hitting it w/ soapUi ?  thats a great tool for development.

Is there something that can be used to generate the WSDL?


there are some things, but they are all independent projects, heres one for
example,
http://www.jool.nl/new/index.php?file_id=1

if you just google around a while for things like "php wsdl generator" you
can find some.  i found something that looked good a few weeks back, but
having no immediate need for it, ive not used it, and dont recall where to
find it =/


> Should I just abandon PHP5's SOAP and use NuSOAP?


obviously nusoap will be slower, but ive found the integrated php soap stuff
to be a little lean on the feature side.  for example, when someone was
trying to work w/ soap attachments recently (client side issue [obviously])
it appears there is no such support in the c code.  i did find some xml in
the .phpt files that had the attachments, but there were no unit tests that
used them.

i found some stuff in one of the soap packages in pear that did handle soap
attachments, but again, this code is php, not c.  to summarize, the
integrated support for soap in php is great because its fast and you dont
have to do anything but include it in the php installation to use it.  the
lacking features can be a bit painful tho.  SoapClient is great, but server
side, if i ever have a need in my personal stuff for soap web services, ill
probly use java as its way more mature in this arena (and fast :D).

-nathan

--- End Message ---
--- Begin Message ---
On Fri, Jun 6, 2008 at 6:33 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> On Fri, Jun 6, 2008 at 2:53 PM, Dan Joseph <[EMAIL PROTECTED]> wrote:
>
>> Hi Everyone,
>>
>> I'm struggling with a WSDL trying to make it work right.  I don't even know
>> what to really ask.
>>
>> Basically I've created a WSDL and made a web service in PHP5.  It doesn't
>> seem to validate properly when a .NET client tries to hit
>
>
> have you tried hitting it w/ soapUi ?  thats a great tool for development.
>
> Is there something that can be used to generate the WSDL?
>
>
> there are some things, but they are all independent projects, heres one for
> example,
> http://www.jool.nl/new/index.php?file_id=1
>
> if you just google around a while for things like "php wsdl generator" you
> can find some.  i found something that looked good a few weeks back, but
> having no immediate need for it, ive not used it, and dont recall where to
> find it =/
>
>
>> Should I just abandon PHP5's SOAP and use NuSOAP?
>
>
> obviously nusoap will be slower, but ive found the integrated php soap stuff
> to be a little lean on the feature side.  for example, when someone was
> trying to work w/ soap attachments recently (client side issue [obviously])
> it appears there is no such support in the c code.  i did find some xml in
> the .phpt files that had the attachments, but there were no unit tests that
> used them.
>
> i found some stuff in one of the soap packages in pear that did handle soap
> attachments, but again, this code is php, not c.  to summarize, the
> integrated support for soap in php is great because its fast and you dont
> have to do anything but include it in the php installation to use it.  the
> lacking features can be a bit painful tho.  SoapClient is great, but server
> side, if i ever have a need in my personal stuff for soap web services, ill
> probly use java as its way more mature in this arena (and fast :D).
>
> -nathan
>

nusoap was really simple to get the attachments working correctly.
Perhaps it might not have been as proper with namespace support and
all that mess, but who cares if you can get at your data and it works.
 I saw the PEAR SOAP client did have support but I didn't see any way
whatsoever to get it to work correctly.  I'm sure I could have asked
on the list, but really it should have been documented somewhere.

Other than that, what Nathan said. :)

--- End Message ---
--- Begin Message ---
On Fri, Jun 6, 2008 at 2:09 PM, Tyson Vanover <[EMAIL PROTECTED]> wrote:

> Sorry, I probably should have included the add() function from the parent.
>  As well as all of the parent constructor.
>
> Basically the object takes an array of key=>value pairs and parses them
> into a string for output.  When it takes in the array of pairs it needs to
> check the keys against a list of valid keys.  I have no preference on how to
> store the list of valid keys other than to add more a constructor doesn't
> need to be called.
>
> class parent{
>  $validkeys = 'name,size';
>  $attributes = array();
>
>  __construct($set){
>    foreach($set as $key=>$value){
>      if(isValidKey($key)){
>        $this->attributes[$key] = $value;
>      }
>    }
>  }
>
>  __toString(){
>    $output = "";
>    foreach($this->attributes as $key=>value){
>      $output .= sprintf(TEMPLATE, $key, $value);
>    }
>  }
>
>  __set($key, $value){
>    if(isValidKey($key)){
>      $this->attributes[$key] = $value;
>    }
>  }
>
>  isValidKey($key){
>  ...Something goes here...
>  }
> }
>
> class child extends parent{
> ...All this needs to do is tack on values 'color,shape' to parent's valid
> keys...
> }
>
> class grandchild extends child{
> ...All this needs to do is tack on values 'cost,location' to child's valid
> keys...
> }
>
> Most sub classes won't need anything different from their parent but the
> expanded list of valid keys.


perhaps instead of subclassing you could write a set of decorators, with a
base decorator, that the others extend.  something like this,

class BaseParentDecorator {
  protected $additionalValidKeys = array();
  protected $theParent = null;

  public function __construct($parent) {
    $this->theParent = $parent;
  }

  public function __toString() {
    return $this->theParent->__toString();
  }

  public function __set($key, $value) {
    $this->theParent->$key = $value;
  }

  public function isKeyValid($key) {
    /// determine if key is valid, by looking at $this->validKeys
    /// put that boolean result in a variable, like $isKeyValid, then
    return $isKeyValid || $this->theParent->isKeyValid($key);
  }
}

and now, instead of subclassing parent, to a potentially deep hierarchy, all
your new classes will subclass BaseParentDecorator, so working off your
example from above, we would have something like,

class child extends BaseParentDecorator {
  protected $validKeys = array(/* tacked on values for child */);
}

class grandchild extends BaseParentDecorator {
  protected $validKeys = array(/* tacked on values for grandchild */);
}

then at runtime you simply wrap a child instance by the grandchild instance,
as in

$thing = new grandchild(new child(new parent(array(/* stuff */)));

-nathan

--- End Message ---
--- Begin Message ---
Hi,
I'm working on a script to look for a UUEncoded attachment in an NNTP
message. I'm running into problems with spaces in the filename of the
attachment.
UUEncoded files in the body of a message will start with the word "begin",
then the size of the file, then the name of the file. Then the encoded
file, finaly then a newline with only the word "end" like so:

begin 644 photo.jpg
-encoded image-
end

The script looks for that first line in that order so as not to confuse it
with the word "begin" showing up somewhere else in the message. Here is
the particular line of code that searches for that:

if (preg_match("/^begin\s+[0-9][0-9][0-9]\s+(.+?)\s*\r?\n/m", $body))
The part where you fetch the file name (.+?)\s* is what is causing the problem as when the file name is "a something.jpg" then (.+?) matches a then \s matches the space and the rest is skipped.

The problem I'm running into is with spaces in the file name. For example,
if it starts with this:

begin 644 a_nice_photo.jpg


it works just fine, decodes the image and places it below the text of the
message. But if the line looks like this:

begin 644 a nice photo.jpg

with spaces in the filename, the script seems to stop looking after the
"a", thinks this is just normal text in the message and doesn't decode the
image. This results in the raw UUEncoded text showing up where the image
should.

I'm stumped. Any ideas?

-Allen



--

DeadTOm
http://www.mtlaners.org
[EMAIL PROTECTED]
A Linux user since 1999.

Runar

--- End Message ---

Reply via email to