idShura
@idShura

Как отправить запрос и прочитать ответ по протоколу SOAP c использованием WDSL?

Пытаюсь написать программу на C Sharp которая будет по протоколу SOAP 1.1 отправлять запрос (boolean GetBlock(string Login, string Password, string Text)) и читать ответ.

Подскажите пожалуйста с чего начать или подскажите где можно найти пример кода.

WSDL описание процедур SENDBLOCK и GETBLOCK
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="urn:SysIntf" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="ISysservice" targetNamespace="http://tempuri.org/">
	<message name="SendBlockRequest">
		<part name="Text" type="xs:string"/>
	</message>
	<message name="SendBlockResponse">
		<part name="return" type="xs:boolean"/>
	</message>
	<message name="GetBlockRequest">
		<part name="Login" type="xs:string"/>
		<part name="Password" type="xs:string"/>
		<part name="Text" type="xs:string"/>
	</message>
	<message name="GetBlockResponse">
		<part name="Text" type="xs:string"/>
		<part name="return" type="xs:boolean"/>
	</message>
	<portType name="ISys">
		<operation name="SendBlock">
			<input message="tns:SendBlockRequest"/>
			<output message="tns:SendBlockResponse"/>
		</operation>
		<operation name="GetBlock">
			<input message="tns:GetBlockRequest"/>
			<output message="tns:GetBlockResponse"/>
		</operation>
	</portType>
	<binding name="ISysbinding" type="tns:ISys">
		<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
		<operation name="SendBlock">
			<soap:operation soapAction="urn:SysInt" style="rpc"/>
			<input>
				<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="SysInt" use="encoded"/>
			</input>
			<output>
				<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="SysInt" use="encoded"/>
			</output>
		</operation>
		<operation name="GetBlock">
			<soap:operation soapAction="urn:SysInt" style="rpc"/>
			<input>
				<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="SysInt" use="encoded"/>
			</input>
			<output>
				<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="SysInt" use="encoded"/>
			</output>
		</operation>
	</binding>
	<service name="ISysservice">
		<port binding="tns:ISysbinding" name="ISysPort">
			<soap:address location="http://xxx.xxx.xxx.xxx:yyyy/zzz/soap"/>
		</port>
	</service>
</definitions>



wsdl в проект подключил. Затем я накидал следующий код:

SysClient client = new SysClient();

client.Endpoint.Name = "ISysbinding";

string login = "login";
string password = "password";
string text = "text";

client.Open();

bool response = client.GetBlock(login, password, ref text);

client.Close();

Console.WriteLine(response.ToString());
Console.ReadKey();


При выполнении получаю ошибку:

Unhandled Exception: System.InvalidOperationException:
Could not find default endpoint element that references contract 'ServiceReference1.ISys' in the ServiceModel client configuration section.
This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
  • Вопрос задан
  • 1427 просмотров
Решения вопроса 1
@John_Nash
coder
смотрите в направлении WCF

PS: если коротко: в VisualStudio жмете AddServiceReference, скармливаете линк на wsdl
и пользуйтесь
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
EreminD
@EreminD
Кое-что умею
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы