使用多个参数从 PHP 调用 asp.net web 服务 [英] Call asp.net web service from PHP with multiple parameters

查看:33
本文介绍了使用多个参数从 PHP 调用 asp.net web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 php 页面中使用 SoapClient 类的方法来调用 asp.net 站点中的 Web 服务.

I'm using a method using SoapClient class in a php page to call a web service in an asp.net site.

这是php代码.

$client = new SoapClient("http://testurl/Test.asmx?WSDL");

$params = array( 'Param1'  => 'Hello', 
                'Param2' => 'World!');

$result = $client->TestMethod($params)->TestMethodResult;

echo $result;

问题是,我只得到了第一个参数(Param1)Hello",而 Param2 似乎存在问题.这里是asp.net方法.

The problem is, I'm only getting the first parameter (Param1) "Hello" back and seems like there is an issue with Param2. Here is the asp.net method.

[WebMethod]
public string TestMethod(string Param1, string Param2) 
{
    return Param1 + " " +  Param2; 
}

在响应中获得 Hello World! 我错过了什么?

What am I missing to get Hello World! in the response?

推荐答案

试试这个:

$client = new SoapClient("http://testurl/Test.asmx?WSDL");
$params->Param1 = 'Hello';
$params->Param2 = 'World!';    
$result = $client->TestMethod($params)->TestMethodResult;

这篇关于使用多个参数从 PHP 调用 asp.net web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆