Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中连接到SOAP#_C#_Php_Soap - Fatal编程技术网

C# 在C中连接到SOAP#

C# 在C中连接到SOAP#,c#,php,soap,C#,Php,Soap,我是C#新手,习惯于使用PHP。 在PHP中,我使用以下代码连接到SOAP服务: <? $client = new SoapClient('soapurl.com/soap.php?wsdl'); $createBatch = $client->createBatch('username','password'); $newstring = $createBatch['ResString']; echo $newstring; ?> 但是如何在标签中获取字符串?如何添加web

我是C#新手,习惯于使用PHP。 在PHP中,我使用以下代码连接到SOAP服务:

<?
$client = new SoapClient('soapurl.com/soap.php?wsdl');
$createBatch = $client->createBatch('username','password');
$newstring = $createBatch['ResString'];
echo $newstring;
?>

但是如何在标签中获取字符串?

如何添加web服务引用:
如何调用web服务:

假设您正在使用Visual Studio进行c#开发。为soap服务添加服务引用后,VisualStudio将为您创建强类型类以访问soap服务。如果打开ServiceReference文件夹下的reference.cs文件,可以看到生成的代码。在该文件中,您将看到为所有请求和响应以及接口和soap客户端类生成的各种类型

访问soap服务的代码如下所示

var (var client = new MyServiceSoapClient) {
    var response = client.createBatch('username', 'password');
    string newstring = response.ResString;
}
var (var client = new MyServiceSoapClient) {
    var response = client.createBatch('username', 'password');
    string newstring = response.ResString;
}