SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question SOAP is killing me!

    for some reason, my parameters aren't getting through to a .Net WS that I'm trying to connect with. Following is my code:
    PHP Code:
    $client = new SOAPClient($wsurl,array('trace' => 1));
    $params = array('paymentConfirmationXml'=>$xml'emailAddress'=>$em);
    $result $client->__soapCall('SendConfirmationEmail', array($params));
    echo 
    "RESPONSE:\n" $client->__getLastResponse(); 
    the response I'm getting is basically saying that it didn't have anything to work from. I've talked with the dev on the other side and he doesn't even see my request in the logs. I've pulled my request sent with $client->__getLastRequest() and when he puts it through manually, it works. But it's like the request just isn't getting there. Am I missing something in my code?

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    What do you get with this?
    PHP Code:
    <?php
    $oClient 
    = new SoapClient($sWSDL, array('trace' => true));
    $mResult $oClient->SendConfirmationEmail(array('paymentConfirmationXml' => $sXML'emailAddress' => $sEmail));
    var_dump($mResult);
    ?>
    Or

    PHP Code:
    <?php
    $oClient 
    = new SoapClient('http://rentacenter.com/ETWebService/ETService.asmx?WSDL', array('trace' => true));
    echo 
    $oClient->HelloWorld()->HelloWorldResult;
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    same as I get with my code
    'Unable to queue Triggered Send request. There are no valid subscribers.'
    That's what I get with every example I try.

    HelloWorld works though. No problems if not doing params. I had already checked that out.

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bbolte View Post
    same as I get with my code
    'Unable to queue Triggered Send request. There are no valid subscribers.'
    That's what I get with every example I try.

    HelloWorld works though. No problems if not doing params. I had already checked that out.
    AFAIK this isn't a SOAPClient error, therefore the response must be coming from the WebService.

    The HelloWorld proves connectivity.

    According to this post...
    One major caveat of sending a triggered send through Web Services is that you must make sure that the subscriber’s required attributes are populated prior to sending a triggered send to said subscriber. for example, if Last Name was a required subscriber attribute, and I tried to send to a subscriber without a last name attribute being populated, I would get the error: “Unable to queue Triggered Send request. There are no valid subscribers.
    ... it sounds like the XML you're trying to post is missing some required data. Are you providing the following elements as stated in the WSDL?
    <s:element name="SendConfirmationEmail">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="userID" type="s:string"/>
    <s:element minOccurs="0" maxOccurs="1" name="emailAddress" type="s:string"/>
    <s:element minOccurs="0" maxOccurs="1" name="confirmationKey" type="s:string"/>
    <s:element minOccurs="0" maxOccurs="1" name="confirmationURL" type="s:string"/>
    </s:sequence>
    </s:complexType>
    </s:element>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SilverBulletUK View Post
    AFAIK this isn't a SOAPClient error, therefore the response must be coming from the WebService.
    That is correct...

    Quote Originally Posted by SilverBulletUK View Post
    The HelloWorld proves connectivity.
    yep

    Quote Originally Posted by SilverBulletUK View Post
    it sounds like the XML you're trying to post is missing some required data. Are you providing the following elements as stated in the WSDL?
    that's the whole issue, according to $client->__getLastRequest(), the xml is complete, as I stated, if I send that to the developer, it runs fine. However, the parameters aren't getting to the service for some reason.

    According to a comment at the manual, "Until php 5.2.9 (at least) the soap extension is only capable of understanding wsdl 1.0 and 1.1 format". This is a WSDL 2.0 service. Might be my issue?

    Another commenter said, "To save yourself a couple days of heart-ache, if you are trying to access a Windows server using SOAP and it seems as though the parameters are not being passed through to the Windows server, it is because of a bug in PHP. Because if you examine the SOAP packets going out (with Wireshark), you'll see that the parameter names are there in the <soap:Body>, but they have no values."

    So, it may be PHP SOAP specifically. I looked at NuSOAP, but haven't tried it yet. It didn't look like it could handle WSDL 2.0 either. I may have to try just in case though.

    Thanks for the help.

  6. #6
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bbolte View Post
    Another commenter said, "To save yourself a couple days of heart-ache, if you are trying to access a Windows server using SOAP and it seems as though the parameters are not being passed through to the Windows server, it is because of a bug in PHP. Because if you examine the SOAP packets going out (with Wireshark), you'll see that the parameter names are there in the <soap:Body>, but they have no values."
    I was going to suggest you to take a dump with Wireshark, just to make sure about what goes over the wire. It's pretty easy to use, although it won't help you much if the connection is SSL-encrypted.

    Another option could be to use soapUI to test the service. If the service doesn't work from soapUI, then the service is at fault, but if it does then it points to PHP SOAPClient as the offender. In this case, you can use soapUI to create a mock service (Eg. it looks exactly as the real service, but it's emulated by soapUI). You can then try to connect to this from your PHP script. soapUI will let you see exactly what the client (PHP SOAPClient) sends.

    Quote Originally Posted by bbolte View Post
    So, it may be PHP SOAP specifically. I looked at NuSOAP, but haven't tried it yet. It didn't look like it could handle WSDL 2.0 either. I may have to try just in case though.
    NuSOAP is a mess. You can always resort to handcraft the XML documents and send them over HTTP directly. It's tedious, but if you only need to call a few methods, then it is doable. soapUI comes handy for this, as it can show a template of how the request should be crafted.

    And yes - SOAP is a crime to humanity.

  7. #7
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken View Post
    And yes - SOAP is a crime to humanity.
    Absolutely!

    Oh and thanks, I'll give soapUI and run.

  8. #8
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, may have just noticed something. My parameters appear to be in the wrong place in the Request XML:
    Code:
    <SOAP-ENV:Envelope 
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:ns1="http://tempuri.org/" 
      xmlns:ns2="http://XXXXXXXXXXXXXXXXXXX">
      <SOAP-ENV:Header>
        <ns2:AuthHeader><ns2:paymentConfirmationXml>XXXXXXXXXXXXXXXXX</ns2:paymentConfirmationXml>
       <ns2:emailAddress>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</ns2:emailAddress>
        </ns2:AuthHeader>
      </SOAP-ENV:Header>  
      <SOAP-ENV:Body>
        <ns1:SendConfirmationEmail/>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    but the service WSDL/example has then in the body. So why is PHP SOAP doing it that way?

  9. #9
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes!
    PHP Code:
    $result $client->__soapCall('SendPaymentConfirmationEmail', array(array('paymentConfirmationXml' => $xml'emailAddress' => $em))); 
    that did it. weird...

  10. #10
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Weird indeed.

    Congrats Bill, well deduced.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •