0

I'm relatively new to PHP, and totally new to VB.NET / Web Services / SOAP / XML, and i'm having trouble to make my PHP communicate with the VB.NET web service.

This is my PHP script:

<?php
    $client = new SoapClient("http://10.0.0.2/wsteste/Service1.asmx?wsdl");
    $param = array("usuario" => "name", "senha" => "test");
    $response = $client->__soapCall("HelloWorld", $param);  
    print_r($response);
?>

And here is the VB.NET asmx.

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Service1
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld(ByVal usuario As String, ByVal senha As String) As String
        Return usuario & " - " & senha
    End Function

End Class

And here is what printed on the browser:

stdClass Object ( [HelloWorldResult] => - )

It was supposed to return name - test, wasn't it?

ghaschel
  • 1,313
  • 3
  • 20
  • 41

1 Answers1

1

I think that the PHP SOAP Client is passing the parameters without the names. So usuario nor senha means nothing to the HelloWorld method.

I would try something like

$client->HelloWorld(array("usuario"=>"name", "senha"=>"test"));

Haven tested though.

EDIT

From this question Call asp.net web service from PHP with multiple parameters

Pass your params like this

$params->usuario = 'name';
$params->senha = 'test';
$client->HelloWorld($params);
Community
  • 1
  • 1
Ateszki
  • 2,243
  • 1
  • 16
  • 13
  • Nop, still returning `stdClass Object ( [HelloWorldResult] => - )` thank you, anyway =) – ghaschel Mar 26 '13 at 12:48
  • Can you use firebug or similar to see whats the PHP soap message format is? I think that would give you a clue – Ateszki Mar 26 '13 at 13:40
  • it wont show me anything besides the returned message, with firebug and firephp – ghaschel Mar 26 '13 at 13:56
  • The things is that the method is returning a concat string. But the 2 input vars are empty. So either the client is not sending them or is sending them incorrectly. I'm not very experienced in .net webservices, and I don't know how to debug it. – Ateszki Mar 26 '13 at 14:01
  • What do you mean the vars are empty? Am i not setting a value to `usuario` var with `"usuario" => "name"`? – ghaschel Mar 26 '13 at 14:05
  • Still returning me the same – ghaschel Mar 26 '13 at 14:12
  • Changed the VB.net web service to C#, and it started to work. Thank you for your help – ghaschel Mar 26 '13 at 14:54