I
I
idShura2018-01-24 12:34:18
SOAP
idShura, 2018-01-24 12:34:18

How to send request and read response via SOAP protocol using WDSL?

I'm trying to write a C Sharp program that will send a request using the SOAP 1.1 protocol (boolean GetBlock (string Login, string Password, string Text)) and read the response.
Please tell me where to start or tell me where you can find an example code.

WSDL description of SENDBLOCK and GETBLOCK procedures
<?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 included in the project. Then I put in the following code:
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();

When executing, I get the error:
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.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
John_Nash, 2018-01-24
@idShura

look in the direction of WCF
PS: in short: in VisualStudio, click AddServiceReference, feed the link to wsdl
and use

D
Dmitry Eremin, 2018-01-24
@EreminD

https://stackoverflow.com/questions/4791794/client...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question