doulai5585 2013-03-26 12:26
浏览 54
已采纳

从PHP使用VB.NET Web服务

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?

  • 写回答

1条回答 默认 最新

  • dongzuoyue6556 2013-03-26 12:40
    关注

    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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了