3

I'm trying to use a SOAP service called Chaverweb. I have their WSDL; it's here.

When I try to make a simple request like GetCWVersion, it's working, but whenever I try to request a function that would need some sort of authentication, like Get_Syn_Comsend (getting an institute's details), it doesn't work.

I tried setting AuthHeader as specified in the WSDL, but it's not working.

Here's my code. I'm hoping there's something obvious I'm not doing since this is my first time working with SOAP:

try {
    $soapClient = new SoapClient('https://www.chaverweb.net/Synagogue.asmx?WSDL');
    $header = new SoapHeader('https://www.chaverweb.net/webservices/', 'AuthHeader', array("Username"=>"[email protected]", "Password"=>"...", "SynKey"=>"..."), false);
    $header2 = new SoapHeader('https://www.chaverweb.net/webservices/', 'SFHeader', array("sf"=>""), false);


    $soapClient->__setSoapHeaders(array($header, $header2));
    $versionResponse = $soapClient->Get_Syn_Comsend();
    print_r($versionResponse);
} catch (SoapFault $exception) {
    echo "Exception: " . $exception->getMessage();
}

This, by the way, gives me: stdClass Object ( ) Thank you very much!

4
  • can you clarify what "not working" means? did you get an error? if so, what was that error. Commented Mar 5, 2015 at 0:01
  • It's returning a blank stdClass- the page shows stdClass Object ( ) Commented Mar 5, 2015 at 0:17
  • Formatting & grammar fixes. Commented Mar 5, 2015 at 17:46
  • Are the credentials in your question the actual credentials? Commented Mar 17, 2015 at 19:38

1 Answer 1

4
+50

so I did some direct testing and it is very simple:

INVALID LOGIN is being returned on the WSDL.

http://phpfiddle.org/main/code/3pvp-8wi9

You can view my code and testing here. While you are testing use their bulit in TestFunction() instead of the function you want to run, this way you can see where the error is. Let me know how I can be of more assistance.

BEFORE EDIT, THIS WAS MY RESPONSE:

You first need to make sure that the last request you sent to complete the function has no errors. As well check that the response was received. This may help debug why you are getting this to begin with. Just add these two lines of code and let us know what you see:

print_r($soapClient->__getLastRequest());
print_r($soapClient->__getLastResponse());

The key here is to make sure you are receiving the response correctly. Post this response and I will gladly help you debug it.

Just food for thought, here is how I would set up this request (this is NOT tested) but the definition in your wsdl shows you need to be using literal and SoapClient does not always use the correct document type when interpreting the response:

ini_set("soap.wsdl_cache_enabled", "0");
try {
$options = array('trace'=>1,
                 'exceptions'=> 1,
                 'style'=> SOAP_DOCUMENT,
                 'use'=> SOAP_LITERAL 
                ); 

$soapClient = new SoapClient('https://www.chaverweb.net/Synagogue.asmx?WSDL',$options);
$header = new SoapHeader('https://www.chaverweb.net/webservices/', 'AuthHeader', array("Username"=>"[email protected]", "Password"=>"demo1234!", "SynKey"=>"T21982011213"), false);
    $header2 = new SoapHeader('https://www.chaverweb.net/webservices/', 'SFHeader', array("sf"=>""), false);


    $soapClient->__setSoapHeaders(array($header, $header2));
    $versionResponse = $soapClient->Get_Syn_Comsend();

    print_r($versionResponse->Get_Syn_ComsendSoapOut);

    } catch (SOAPFault $f) {
     print $f;
    }

Hope this helps in some way! Send your results for further assistance :)

POST EDIT FOR SIMPLEXML TEST: replace:

print_r($versionResponse->Get_Syn_ComsendSoapOut);

with this:

$data = simplexml_load_file($versionResponse->Get_Syn_ComsendSoapOut);
print_r($data);

See what it gives you, hopefully it either throws a descriptive error or it processes the result (very rare, but possible)!

Sign up to request clarification or add additional context in comments.

8 Comments

Tried adding, in your two lines, and this is what I got back: stdClass Object ( ) Exception: Function ("_getLastRequest") is not a valid method for this service
Then it seems like it is transfering it to am xml like format. Have you tried just a simplexml_load_string? Not very common that this should happen. It is no longer considering it as a soap call.
Do you have the actual page you are testing to see the response?
I don't understand what you mean by try simplexml_load_string... sorry, I'm very new to SOAP
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.