2013-03-26 63 views
0

我對PHP比較陌生,對VB.NET/Web服務/ SOAP/XML完全陌生,而且我很難讓我的PHP與VB通信。 NET網絡服務。從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

我認爲PHP SOAP客戶端傳遞的參數沒有名稱。所以usuario和senha對HelloWorld方法沒有任何意義。

我會嘗試像

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

避風港,雖然測試。

編輯

從這個問題Call asp.net web service from PHP with multiple parameters

通過您的PARAMS這樣

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

NOP,還是返回'stdClass的對象([HelloWorldResult] => - )'謝謝你,反正=) – ghaschel 2013-03-26 12:48:40

+0

你可以使用螢火蟲或類似的東西看看PHP肥皂訊息格式是什麼?我認爲這會給你一個線索 – Ateszki 2013-03-26 13:40:22

+0

它不會告訴我除了返回的消息,螢火蟲和firephp之外的任何東西 – ghaschel 2013-03-26 13:56:43