How to solve the problem of function doesn ' t exist in laravel5.1-php using soap?

Source: Internet
Author: User
Tags soap client
In the next novice, is using LaravelFramework and xamppBuild a backend management system. Because there is a need to do the WebService interface function, the use of soap in PHP, but the development process has emerged Function doesn't existProblem, the card for a long time, so come to help. Specific as follows:

There are so two PHP files:
①client.php, as a SOAP client
Path:C:\xampp\htdocs\my_project\app\Services\client.php


  
    "http://localhost/my_project/app/Services/server.php", 'uri' => "http://localhost/", 'encoding' => 'UTF-8'));    echo $client->hello();} catch (SoapFault $fault) {    echo "Error: ", $fault->faultcode, ", String: ", $fault->getMessage();}

②server.php, as a soap service side
Path:C:\xampp\htdocs\my_project\app\Services\server.php


  
    "localhost"));    $soap->addFunction('hello');    $soap->handle();}catch (\SoapFault $fault) {    echo "Error: ", $fault->faultcode, ", String: ", $fault->faultstring;}function hello(){    $model = new User;    return "hello";}

Because there is a need to use a template, it is server.php used in namespace , and the User way in which classes are use referenced. But server.php in this way SoapServer , a slash is SoapFault added to the front \SoapServer and\SoapFault

Finally in the browser run C:\xampp\htdocs\my_project\app\Services\client.php when the Error: SOAP-ENV:Server, String: Function 'hello' doesn't exist error prompted, Baidu Google has not been the result, hope that experienced predecessors can point out, greatly appreciated!

Reply content:

Under Novice, the framework is being used Laravel and xampp a backend management system is being built. Because there is a need to do WebService interface function, the use of soap in PHP, but the development process occurred in Function doesn't exist the problem, card for a long time, so come to help. Specific as follows:

There are so two PHP files:
①client.php, as a SOAP client
Path:C:\xampp\htdocs\my_project\app\Services\client.php


  
    "http://localhost/my_project/app/Services/server.php", 'uri' => "http://localhost/", 'encoding' => 'UTF-8'));    echo $client->hello();} catch (SoapFault $fault) {    echo "Error: ", $fault->faultcode, ", String: ", $fault->getMessage();}

②server.php, as a soap service side
Path:C:\xampp\htdocs\my_project\app\Services\server.php


  
    "localhost"));    $soap->addFunction('hello');    $soap->handle();}catch (\SoapFault $fault) {    echo "Error: ", $fault->faultcode, ", String: ", $fault->faultstring;}function hello(){    $model = new User;    return "hello";}

Because there is a need to use a template, it is server.php used in namespace , and the User way in which classes are use referenced. But server.php in this way SoapServer , a slash is SoapFault added to the front \SoapServer and\SoapFault

Finally in the browser run C:\xampp\htdocs\my_project\app\Services\client.php when the Error: SOAP-ENV:Server, String: Function 'hello' doesn't exist error prompted, Baidu Google has not been the result, hope that experienced predecessors can point out, greatly appreciated!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.