0

We have the following scenario:

  1. Setup a web service - wsdl and all, supposed to be listening for data sent by the client, receive it, do stuff with it and send a response as 'ok' if everything is okay, and 'false' if something died
  2. Client side runs a script that generates the soap/xml request bit, creates a soap client and sends the request to the wsdl.
  3. Client side gets a result indicating that the data was not processed by the web service - false. And the web service receives no data at all.

I don't have access to the web service - it is someone else's. The generated request body (the whole etc.) is being generated correctly - when I send it through soapUI it works, but not through my php soap client.

I tried using the built-in Soap with the SoapClient, __doRequest, __call (kind of tried everything), but nothing happens - still getting 'false' result. I tried re-writing the NuSoap in order to work with Soap 1.2, but still only a 'false' result for something that returns true.

So, I was wondering if someone can answer me the following questions:

  1. on the server do I need something specially install to get it to work with Soap 1.2 ?

  2. When the client has to send data to the web service's function do I use __doRequest or __call? Or something else?

  3. According to my php.ini the server header_accept values do not have the application/soap+xml that is needed to work with soap 1.2 - could this be the problem, if yes - back to question 1, or how can I add the type to the header_accept?

EDIT:

$client = new SoapClient(
    "the_wsdl_url_correct_for_sure.wsdl", 
    array(
       'soap_version' => SOAP_1_2, 
       'trace'        => 1,
    )
);

$result = $client->__doRequest(
    $the_var_i_use_to_store_the_soap_xml_thingie_that_works_through_soapUI_so_it_is_correct, $location, 
    $the_function_I_try_to_call, 
    "1.2"
);

For $location I am the namespace of the action (the function I'm trying to call and send the data from the first parameter to). And for the action/function I tried using just the name of the action as it's defined in the namespace, and using the full path with the "full_namespace/action"

Should I use __doRequest or __call when I'm trying to send the data to the WSDL?

EDIT2:

The request I'm sending is:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <env:Header/>
   <env:Body>
      <ns2:FunctionName xmlns:ns2="namespace_of_the_service">
         <arg0>
              <data1>Some data</data1>
           </arg0>
       </ns2:FunctionName>
   </env:Body>
</env:Envelope>

More about the problems from this can read in my previous post: PHP Soap Client - sending the wrong headers "soapenv:VersionMismatch"

Community
  • 1
  • 1
Iv3
  • 11
  • 1
  • 3
  • There can be many reasons. Best suggestions I can give: Get a recent PHP version. Use the built-in `SoapClient` class for starters, it supports SOAP 1.2. You most likely provide the wrong argument. Are you in WSDL mode or not? Where is your code (stick to SoapClient with an example code here if you ask me)? – hakre Feb 06 '13 at 14:27
  • Unfortunately, I do not have access to the server - can't reconfigure it on my own :/ And I did use the built in Soap, but it kept giving me error about mismatched versions of the Soap, from which I concluded that it simply doesn't support 1.2... or something is dying along the way. I will add my soapClient code and the request in my main post. – Iv3 Feb 06 '13 at 14:40
  • If you get a concrete error message, add it to your question. Also enable debug mode of the SoapClient class and see the SOAP request and response verbatim. You might want to add those two to your question as well. – hakre Feb 06 '13 at 14:41
  • I have this enabled, but I do not get any errors. – Iv3 Feb 06 '13 at 14:48
  • Please see [Debugging PHP SOAP call](http://stackoverflow.com/q/3973979/367456) - It works by enabling the **trace** mode of `SoapClient`, explained with the docs for [`SoapClient::__getLastResponse`](http://php.net/SoapClient.getLastResponse). - Then check the request and the response XML of the SOAP communication. – hakre Feb 06 '13 at 14:52

1 Answers1

0

The way you ask your question(s) here does not work well with Stackoverflow, I leave this here as a comment, not as an answer, just to show you that you don't go much ahead in getting these answerwed:

  1. on the server do I need something specially install to get it to work with Soap 1.2 ?

    No, a recent PHP version with the Soap extension is enough.

  2. When the client has to send data to the web service's function do I use __doRequest or __call? Or something else?

    That depends on the mode (WSDL or not) and as well on what you want to do. What WSDL is and what WSDL mode is, please read the whole Soap book in the PHP manual from start to end and as well I suggest because the documentation is not perfect you make yourself comfortable with what WSDL is and some third-party WSDL SoapClient examples which both you can find through the internet search engine of your choice. For __doRequest please see the manual what you can do with it. For __call the manual clearly says for what it is for and that it is deprecated and so you're probably looking for __soapCall instead.

  3. According to my php.ini the server header_accept values do not have the application/soap+xml that is needed to work with soap 1.2 - could this be the problem, if yes - back to question 1, or how can I add the type to the header_accept?

    That might be according to your php.ini, I mean you can write in there what you want, however according to PHP documentation itself there is no header_accept PHP ini directive. Please double check what is written in the PHP.ini and then double-check with the documentation of that directive inside the PHP manual if or if not it controls what you like to control - or if already set - that it does not set something that might stand in your way.

    As far as I know for a SoapClient you don't need to set any PHP ini based header accept directive (even next to that that one actually does not exist!) to get it working. It works with the default configuration, so you don't need to add anything.

    Which makes me wonder why you actually ask? What makes you think you would need to add anything to that (by you not further specified) ini setting?

hakre
  • 193,403
  • 52
  • 435
  • 836
  • Well, in order to use Soap 1.2 the sent headers have to be of content-type application/soap+xml instead of text/xml. I used both getLastRequestHeaders and getLastResponseHeaders and they both say 'content-type text/xml', while in soapUI the raw data shows for both content type of application/soap+xml - that was why I thought that maybe this type should be included in the accepted headers of the server. – Iv3 Feb 06 '13 at 14:51
  • Okay, that can be an issue, however, don't jump to conclusions which php.ini directive might be related to that too fast. For the rest of your questions, I think most of it should be clarified via the PHP manual, so it's not that clear to me why you ask (or for what you ask specifically). For example `__call` (redirecting to `__soapCall` ) says already what's it's role (or not) in WSDL mode (you normally do not use it in WSDL mode). – hakre Feb 06 '13 at 14:57
  • And most likely the error is `$the_var_i_use_to_store_the_soap_xml_thingie_that_works_through_soapUI_so_it_is_correct` because this assumption can be totally wrong. The PHP soap client is not soapUI, so you need to use the correct soap type in PHP for that SOAP parameter as a PHP function parameter. Unfortunately you didn't share what that specifically is. Also the concrete WSDL URI is missing in your question, as well as the concrete method names etc., which makes this very hard to follow. When asking a question be precise and include the needed information. – hakre Feb 06 '13 at 14:59
  • Because just by the specs, you only need to do it right and it works. – hakre Feb 06 '13 at 15:00
  • I read and re-read the SOAP Manual, I tried everything possible, and everything that is dumb and shouldn't be possible, but I just cannot get it to work, so I'm already shooting in the darkness/panic/despair. The last slightly logical explanation that I can come up with is the server not supporting the headers I need, but as I'm not all that familiar with server re-configuration(more or less a newbie), I decided to ask here... – Iv3 Feb 06 '13 at 15:02
  • P.S. I added the request code and a link to my previous problem in the first post. – Iv3 Feb 06 '13 at 15:05
  • It's okay to ask however unless you can't make clear what specififally you ask about it's just hard (if not impossible) to answer. That's all I care about right now. Add the XML of the request and response to your question. Do this for two things: First for the request done by soapUI (if soapUI does not support giving you the data, grab it with a network sniffer). Second do this for the request done with PHP's `SoapClient`. Add the WSDL so it can be verified what the issue is. – hakre Feb 06 '13 at 15:06
  • The last request is the same as the one I've posted above, and the last response is NULL. – Iv3 Feb 06 '13 at 15:08
  • The response is NULL? Really? Check also for more errors by increasing the PHP error level to maximum setting and display / log PHP errors. See [How to get useful error messages in PHP?](http://stackoverflow.com/q/845021/367456). And the WSDL is missing. Also as the response is NULL, you need to go one step deeper and use a network sniffer to get the full HTTP response. – hakre Feb 06 '13 at 15:10
  • Well if I do it through the PHP SOAP, I get 'HTTP1.1 500' response header, if I do it through my version of NuSoap with everything changed to work with the 1.2 version, I get false as a response from the server, and a 'HTTP 1.1 200 OK' response header, but in this case I cannot use the php SOAP functions... – Iv3 Feb 06 '13 at 15:28
  • What does your network sniffer gives you? If you don't want to run one, you can alternatively replace the network layer of SoapClient and run the request your own, e.g. with PHP curl extension making use of verbose mode. See [Php - Debugging Curl](http://stackoverflow.com/questions/3757071/php-debugging-curl) - The WSDL is still missing. The correct request and response XML from SoapUI is still missing. – hakre Feb 06 '13 at 15:37