Hello im trying to get a hello world program to work from c# to wcf and then call it with php
now have gone as far as i can get.

You have created a service.

To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:

svcutil.exe http://localhost:8731/phpwcf/?wsdl
This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:

C#

class Test
{
    static void Main()
    {
        Service1Client client = new Service1Client();

        // Use the 'client' variable to call operations on the service.

        // Always close the client.
        client.Close();
    }
}

So i guess that means the problem does not lie with the c# but the php part
my php code looks like this

<?php
    $client = new SoapClient("http://localhost:8731/phpwcf/?wsdl");
    $args = array('text' => 'Hello World');
    $response = $Client->ENtoJP($args);
    echo $response->ENtoJPResult;
?>

and <add baseAddress = "http://localhost:8731/phpwcf/" />

is correct and i have included my method like so

[OperationContract]
string ENtoJP(string text);

method looks like this

public string ENtoJP(string text)
        {
            if (text.Equals("Hello World", StringComparison.CurrentCultureIgnoreCase))
            {
                return "Ohayou Sekai";
            }
            else
            {
                return "Could not translate.";
            }
        }

should'nt be any problems (but what do i know) xD

My php version is 5.4.3 and as i understood you need 5 or higher and i have uncommented the
extension=php_soap.dll
so my question is why do i still get error? :O whats wrong?!

i get the errors

Notice: Undefined variable: Client in C:\wamp\www\test\test.php on line 13
Fatal error: Call to a member function ENtoJP() on a non-object in C:\wamp\www\test\test.php on line 13

Thank you for answers :)

Recommended Answers

All 3 Replies

Adam.Adamski.96155
What? should it look like

<?php

    $client:$client = new SoapClient("http://localhost:8731/phpwcf/?wsdl");


    $args = array('text' => 'Hello World');
    $Client:$response = $Client->ENtoJP($args);

    echo $response->ENtoJPResult;

?>

wont work either :P or what do you mean

EDIT : ok i see now .... wow so many things it can be and its a stupic case letter xD embarrassing
well thank you so much adam :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.