SOAP Over https gives errors logging in

I am testing the SOAP Server over HTTPS and the server has a valid certificate. Let me first state that everything works perfectly over HTTP, but when trying to use the LoginUser method over https, I get the following error:

    PHP Fatal error: Procedure 'LoginUser' not present in /opt/matrix/packages/web_services/soap_server/soap_server.inc on line 231


I also dumped out the results of $HTTP_RAW_POST_DATA and got:

    [09-Nov-2012 12:00:21] PHP Fatal error: Uncaught exception 'Exception' with message 'Unable to parse SOAP request "<?xml version="1.0" encoding="utf-8" ?>' in /opt/matrix/packages/web_services/soap_server/soap_server.inc:197
    Raw Entry: 	Stack trace:
    Raw Entry: 	#0 /opt/matrix/packages/web_services/soap_server/soap_server.inc(125): Soap_Server->service('<?xml version="...')
    Raw Entry: 	#1 /opt/matrix/core/include/mysource.inc(787): Soap_Server->printFrontend()
    Raw Entry: 	#2 /opt/matrix/core/web/index.php(30): MySource->start()
    Raw Entry: 	#3 {main}
    Raw Entry: 	thrown in /opt/matrix/packages/web_services/soap_server/soap_server.inc on line 197


Looking at my WSDL file over https, I see that it has the LoginUser method shown.

Is there a reason why this wouldn't work over HTTPS and why it wouldn't find that SOAP function when it finds it fine over HTTP?

We are using Squid if that could be the issue...

[quote]
I am testing the SOAP Server over HTTPS and the server has a valid certificate. Let me first state that everything works perfectly over HTTP, but when trying to use the LoginUser method over https, I get the following error:


    PHP Fatal error: Procedure 'LoginUser' not present in /opt/matrix/packages/web_services/soap_server/soap_server.inc on line 231


I also dumped out the results of $HTTP_RAW_POST_DATA and got:

    [09-Nov-2012 12:00:21] PHP Fatal error: Uncaught exception 'Exception' with message 'Unable to parse SOAP request "<?xml version="1.0" encoding="utf-8" ?>' in /opt/matrix/packages/web_services/soap_server/soap_server.inc:197
    Raw Entry: 	Stack trace:
    Raw Entry: 	#0 /opt/matrix/packages/web_services/soap_server/soap_server.inc(125): Soap_Server->service('<?xml version="...')
    Raw Entry: 	#1 /opt/matrix/core/include/mysource.inc(787): Soap_Server->printFrontend()
    Raw Entry: 	#2 /opt/matrix/core/web/index.php(30): MySource->start()
    Raw Entry: 	#3 {main}
    Raw Entry: 	thrown in /opt/matrix/packages/web_services/soap_server/soap_server.inc on line 197


Looking at my WSDL file over https, I see that it has the LoginUser method shown.

Is there a reason why this wouldn't work over HTTPS and why it wouldn't find that SOAP function when it finds it fine over HTTP?

We are using Squid if that could be the issue...
[/quote]

Not really sure here, possible things to check:
  • The WSDL has HTTPS urls and not HTTP (this might need a code change it could be a bug)[*]Squid *may* be affecting it, try to remove it or by pass it.[*]Check for any PHP bugs, from memory I think there was one in the past but that should be fixed now.

[quote]
Not really sure here, possible things to check:

  • The WSDL has HTTPS urls and not HTTP (this might need a code change it could be a bug)[*]Squid *may* be affecting it, try to remove it or by pass it.[*]Check for any PHP bugs, from memory I think there was one in the past but that should be fixed now.

[/quote]

I am at a loss here. I have done the following:

- Verified we have an https URL.
- Tried to bypass squid by using _nocache
- Looked for any php bugs
- Debugged the SOAP php calls. I cannot find any differences in the http and https calls I make.

The strange thing is, when I call the LoginUser function on both http and https, I look at the service() function in soap_server.inc and log the var $function_names, they are both exactly the same. Over https I still see the LoginUser function listed.

Not sure what else to do, I am going to submit a bug report.

I tested it locally and it works on https url.
I generated the WSDL in backend with http url. But it doesn't seem to matter anyway.



Can you show me what code you use and how to replicate the error?


    $client = new SoapClient("https://whiskey.labs.squiz.net.au/ewang_dev/_web_services/soap-server/_nocache?WSDL", array('login'          => "root",
                                                        'password'       => "root"));
    $result = $client->loginUser(Array('Username' => 'root', 'Password' => 'root'));
    
    var_dump($result);

[quote]
Can you show me what code you use and how to replicate the error?


    $client = new SoapClient("https://whiskey.labs.squiz.net.au/ewang_dev/_web_services/soap-server/_nocache?WSDL", array('login'          => "root",
                                                        'password'       => "root"));
    $result = $client->loginUser(Array('Username' => 'root', 'Password' => 'root'));
    
    var_dump($result);

[/quote]



I am not using PHP to make the SOAP request, so I am not sure if you want to see my Objective-C code, but here it goes:


    
    // A bunch more code above that defines the site config
    
    // Create the XML string that will be used to create our asset
    NSString *xml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
                 ""
                 ""
                 ""
                 ""
                 ""
                 ""
                 ""
                 "", config.soapURL, config.username, config.password];
    
    // Setup the connection
    NSString *wsdlURL = [NSString stringWithFormat:@"%@?WSDL", config.soapURL];
    NSURL *serviceUrl = [NSURL URLWithString:wsdlURL];
    NSMutableURLRequest *serviceRequest = [NSMutableURLRequest requestWithURL:serviceUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
    [serviceRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-type"];
    [serviceRequest setHTTPMethod:@"POST"];
    [serviceRequest setHTTPBody:[xml dataUsingEncoding:NSUTF8StringEncoding]];
    
    // Create the operation
    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:serviceRequest];
    
    // A bunch more code that involves retrieving the response, etc.


Not sure I want to post the actual URL to my Soap Server...

Would adding _nocache bypass Squid? Still doesn't work doing that...

I am buying a new certificate for another site to site on, and I will report back here with the results.

[quote]
I tested it locally and it works on https url.

I generated the WSDL in backend with http url. But it doesn't seem to matter anyway.

[/quote]



Ok, just bought a brand new SSL certificate for my new site, on a different server from my other test, and installed it correctly. Matrix serves me the HTTPS URL to the SOAP Server and I can preview it.



But when trying to login, I get the exact errors as before:


    Procedure 'LoginUser' not present

So, it looks like I figured out what the issue was. The targetNamespace in the wsdl was only using http:// rather than https://. It looks like I generated the WSDL file when I was logged into our _admin using http rather than https. Regenerating the WSDL while logged in as https fixed the issue.


Hooray! Not a Matrix bug! This will be good news for my users. :slight_smile: