Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set soapHeader to authenticate in c#?
    text
    copied!<p>I want to write a c# client to consume a web service ,after i add service reference and get a proxy class , i write code like this:</p> <pre><code> private void button1_Click(object sender, EventArgs e) { servicePortTypeClient sc = new servicePortTypeClient(); string stID=sc.getTableByTitle("Equipment"); } </code></pre> <p>but when i run this code, i get a exception of : wrong parameters for authorization</p> <p>there are some code of how to use this web service,but the code is written by php,below is the sample:</p> <pre><code> $client = new SoapClient( 'https://rtu2/mvtspro/extensions/service/?wsdl', array( 'timeout' =&gt; 1000 ) ); $headers = array(); $headers[] = new SoapHeader('http://merasystems.com/auth','Login','admin'); $headers[] = new SoapHeader('http://merasystems.com/auth','Password','admin'); $client-&gt;__setSoapHeaders($headers); </code></pre> <p>i guess maybe i have some error about how to authenricate with the server,but i don't know how to write code to do it,can anybody figure it out? </p> <p>below is th wsdl document of the service:</p> <pre><code> &lt;s:complexType name="rowset"&gt; &lt;s:complexContent&gt; &lt;s:restriction base="ns:Array"&gt; &lt;s:sequence&gt; &lt;s:element name="item" type="ns3:row" maxOccurs="unbounded"/&gt; &lt;/s:sequence&gt; &lt;s:attribute ref="ns:arrayType" arrayType="ns3:row[]" /&gt; &lt;/s:restriction&gt; &lt;/s:complexContent&gt; &lt;/s:complexType&gt; &lt;s:complexType name="row"&gt; &lt;s:complexContent&gt; &lt;s:restriction base="ns:Array"&gt; &lt;s:sequence&gt; &lt;s:element name="item" type="ns3:column" maxOccurs="unbounded"/&gt; &lt;/s:sequence&gt; &lt;s:attribute ref="ns:arrayType" arrayType="ns3:column[]" /&gt; &lt;/s:restriction&gt; &lt;/s:complexContent&gt; &lt;/s:complexType&gt; &lt;s:complexType name="column"&gt; &lt;s:all&gt; &lt;s:element name="name" type="s:string"/&gt; &lt;s:element name="value" type="s:string"/&gt; &lt;/s:all&gt; &lt;/s:complexType&gt; &lt;s:complexType name="sort"&gt; &lt;s:complexContent&gt; &lt;s:restriction base="ns:Array"&gt; &lt;s:sequence&gt; &lt;s:element name="item" type="ns3:sort_item" maxOccurs="unbounded"/&gt; &lt;/s:sequence&gt; &lt;s:attribute ref="ns:arrayType" arrayType="ns3:sort_item[]" /&gt; &lt;/s:restriction&gt; &lt;/s:complexContent&gt; &lt;/s:complexType&gt; &lt;s:complexType name="sort_item"&gt; &lt;s:all&gt; &lt;s:element name="column" type="s:string"/&gt; &lt;s:element name="dir" type="ns3:order_type"/&gt; &lt;/s:all&gt; &lt;/s:complexType&gt; &lt;s:simpleType name="order_type"&gt; &lt;s:restriction base="s:string"&gt; &lt;s:enumeration value="asc"/&gt; &lt;s:enumeration value="desc"/&gt; &lt;/s:restriction&gt; &lt;/s:simpleType&gt; &lt;s:complexType name="filter_childs_arr"&gt; &lt;s:complexContent&gt; &lt;s:restriction base="ns:Array"&gt; &lt;s:sequence&gt; &lt;s:element name="item" type="ns3:filter" maxOccurs="unbounded"/&gt; &lt;/s:sequence&gt; &lt;s:attribute ref="ns:arrayType" arrayType="ns3:filter[]" /&gt; &lt;/s:restriction&gt; &lt;/s:complexContent&gt; &lt;/s:complexType&gt; &lt;s:complexType name="filter"&gt; &lt;s:all&gt; &lt;s:element name="type" type="s:string"/&gt; &lt;s:element name="column" type="s:string" nillable="true"/&gt; &lt;s:element name="operator" type="s:string" nillable="true"/&gt; &lt;s:element name="value" type="s:string" nillable="true"/&gt; &lt;s:element name="childs" type="ns3:filter_childs_arr" nillable="true"/&gt; &lt;/s:all&gt; &lt;/s:complexType&gt; &lt;/s:schema&gt; &lt;/wsdl:types&gt; &lt;message name="insertRowsetRequest"&gt; &lt;part name="p_table_hi" type="s:string"/&gt; &lt;part name="p_rowset" type="ns3:rowset"/&gt; &lt;/message&gt; &lt;message name="insertRowsetResponse"&gt; &lt;part name="result" type="s:integer"/&gt; &lt;/message&gt; &lt;message name="updateRowsetRequest"&gt; &lt;part name="p_table_hi" type="s:string"/&gt; &lt;part name="p_rowset" type="ns3:rowset"/&gt; &lt;part name="p_filter" type="ns3:filter"/&gt; &lt;/message&gt; &lt;message name="updateRowsetResponse"&gt; &lt;part name="result" type="s:integer"/&gt; &lt;/message&gt; &lt;message name="deleteRowsetRequest"&gt; &lt;part name="p_table_hi" type="s:string"/&gt; &lt;part name="p_rowset" type="ns3:rowset"/&gt; &lt;part name="p_filter" type="ns3:filter"/&gt; &lt;/message&gt; &lt;message name="deleteRowsetResponse"&gt; &lt;part name="result" type="s:integer"/&gt; &lt;/message&gt; &lt;message name="selectRowsetRequest"&gt; &lt;part name="p_table_hi" type="s:string"/&gt; &lt;part name="p_filter" type="ns3:filter"/&gt; &lt;part name="p_sort" type="ns3:sort"/&gt; &lt;part name="p_limit" type="s:integer"/&gt; &lt;part name="p_offset" type="s:integer"/&gt; &lt;/message&gt; &lt;message name="selectRowsetResponse"&gt; &lt;part name="result" type="s:anyType"/&gt; &lt;/message&gt; &lt;message name="countRowsetRequest"&gt; &lt;part name="p_table_hi" type="s:string"/&gt; &lt;part name="p_filter" type="ns3:filter"/&gt; &lt;/message&gt; &lt;message name="countRowsetResponse"&gt; &lt;part name="result" type="s:integer"/&gt; &lt;/message&gt; &lt;message name="getTableByTitleRequest"&gt; &lt;part name="p_title" type="s:string"/&gt; &lt;/message&gt; &lt;message name="getTableByTitleResponse"&gt; &lt;part name="result" type="s:string"/&gt; &lt;/message&gt; &lt;message name="describeColumnsRequest"&gt; &lt;part name="p_table_hi" type="s:string"/&gt; &lt;/message&gt; &lt;message name="describeColumnsResponse"&gt; &lt;part name="result" type="s:anyType"/&gt; &lt;/message&gt; &lt;message name="getColumnLookupRequest"&gt; &lt;part name="p_table_hi" type="s:string"/&gt; &lt;part name="p_column_nm" type="s:string"/&gt; &lt;/message&gt; &lt;message name="getColumnLookupResponse"&gt; &lt;part name="result" type="s:anyType"/&gt; &lt;/message&gt; &lt;portType name="servicePortType"&gt; &lt;operation name="insertRowset"&gt; &lt;input message="ns3:insertRowsetRequest"/&gt; &lt;output message="ns3:insertRowsetResponse"/&gt; &lt;/operation&gt; &lt;operation name="updateRowset"&gt; &lt;input message="ns3:updateRowsetRequest"/&gt; &lt;output message="ns3:updateRowsetResponse"/&gt; &lt;/operation&gt; &lt;operation name="deleteRowset"&gt; &lt;input message="ns3:deleteRowsetRequest"/&gt; &lt;output message="ns3:deleteRowsetResponse"/&gt; &lt;/operation&gt; &lt;operation name="selectRowset"&gt; &lt;input message="ns3:selectRowsetRequest"/&gt; &lt;output message="ns3:selectRowsetResponse"/&gt; &lt;/operation&gt; &lt;operation name="countRowset"&gt; &lt;input message="ns3:countRowsetRequest"/&gt; &lt;output message="ns3:countRowsetResponse"/&gt; &lt;/operation&gt; &lt;operation name="getTableByTitle"&gt; &lt;input message="ns3:getTableByTitleRequest"/&gt; &lt;output message="ns3:getTableByTitleResponse"/&gt; &lt;/operation&gt; &lt;operation name="describeColumns"&gt; &lt;input message="ns3:describeColumnsRequest"/&gt; &lt;output message="ns3:describeColumnsResponse"/&gt; &lt;/operation&gt; &lt;operation name="getColumnLookup"&gt; &lt;input message="ns3:getColumnLookupRequest"/&gt; &lt;output message="ns3:getColumnLookupResponse"/&gt; &lt;/operation&gt; &lt;/portType&gt; &lt;binding name="servicePortBinding" type="ns3:servicePortType"&gt; &lt;soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/&gt; &lt;operation name="insertRowset"&gt; &lt;soap:operation soapAction=""/&gt; &lt;input&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/output&gt; &lt;/operation&gt; &lt;operation name="updateRowset"&gt; &lt;soap:operation soapAction=""/&gt; &lt;input&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/output&gt; &lt;/operation&gt; &lt;operation name="deleteRowset"&gt; &lt;soap:operation soapAction=""/&gt; &lt;input&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/output&gt; &lt;/operation&gt; &lt;operation name="selectRowset"&gt; &lt;soap:operation soapAction=""/&gt; &lt;input&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/output&gt; &lt;/operation&gt; &lt;operation name="countRowset"&gt; &lt;soap:operation soapAction=""/&gt; &lt;input&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/output&gt; &lt;/operation&gt; &lt;operation name="getTableByTitle"&gt; &lt;soap:operation soapAction=""/&gt; &lt;input&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/output&gt; &lt;/operation&gt; &lt;operation name="describeColumns"&gt; &lt;soap:operation soapAction=""/&gt; &lt;input&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/output&gt; &lt;/operation&gt; &lt;operation name="getColumnLookup"&gt; &lt;soap:operation soapAction=""/&gt; &lt;input&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mfisoft.ru/soap"/&gt; &lt;/output&gt; &lt;/operation&gt; &lt;/binding&gt; &lt;service name="Service"&gt; &lt;port name="ServicePortType" binding="ns3:servicePortBinding"&gt; &lt;soap:address location="https://111.111.111.20/service/service.php?soap"/&gt; &lt;/port&gt; &lt;/service&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload