从PHP使用VB.NET Web服务

时间:2013-03-26 12:26:59

标签: php .net vb.net web-services soap

我对PHP比较陌生,对VB.NET / Web Services / SOAP / XML来说是全新的,而且我很难让我的PHP与VB.NET Web服务进行通信。

这是我的PHP脚本:

<?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);
?>

这是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

这是打印在浏览器上的内容:

stdClass Object ( [HelloWorldResult] => - )

应该归还name - test,不是吗?

1 个答案:

答案 0 :(得分:1)

我认为PHP SOAP客户端传递没有名称的参数。所以usuario和senha对HelloWorld方法没有任何意义。

我会尝试像

这样的东西
$client->HelloWorld(array("usuario"=>"name", "senha"=>"test"));
但是,哈文试过了。

修改

从这个问题Call asp.net web service from PHP with multiple parameters

像这样传递你的参数

$params->usuario = 'name';
$params->senha = 'test';
$client->HelloWorld($params);