1

I am trying to consume a wsdl file and get a soap response but I always get the error

The HTTP request is unauthorized with client authentication scheme 'Anonymous'.The authentication header received from the server was 'Basic Realm’=myrealm. The remote server returned an error: (401) Unauthorized

Here is my wsdl file

 <?xml version="1.0" encoding="utf-8"?>
    <definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://remittance_ws/rmt_ws.wsdl" name="rmt_ws" targetNamespace="http://remittance_ws/rmt_ws.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/">
        <types>
            <xs:schema targetNamespace="http://remittance_ws/rmt_ws.wsdl" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="UnsupportedEncodingException" type="tns:UnsupportedEncodingException" />
      <xs:element name="remittanceXml" type="tns:remittanceXml" />
      <xs:element name="remittanceXmlResponse" type="tns:remittanceXmlResponse" />
      <xs:complexType name="remittanceXml">
        <xs:sequence>
          <xs:element minOccurs="0" name="inputXML" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="remittanceXmlResponse">
        <xs:sequence>
          <xs:element minOccurs="0" name="return" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="UnsupportedEncodingException">
        <xs:sequence>
          <xs:element minOccurs="0" name="message" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </types>
  <message name="remittanceXml">
    <part name="parameters" element="tns:remittanceXml" />
  </message>
  <message name="remittanceXmlResponse">
    <part name="parameters" element="tns:remittanceXmlResponse" />
  </message>
  <message name="UnsupportedEncodingException">
    <part name="fault" element="tns:UnsupportedEncodingException" />
  </message>
  <portType name="rmt_ws">
    <operation name="remittanceXml">
      <input message="tns:remittanceXml" />
      <output message="tns:remittanceXmlResponse" />
      <fault name="UnsupportedEncodingException" message="tns:UnsupportedEncodingException" />
    </operation>
  </portType>
  <binding name="rmt_wsBinding" type="tns:rmt_ws">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="remittanceXml">
      <soap:operation soapAction="" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
      <fault name="UnsupportedEncodingException">
        <soap:fault use="literal" name="UnsupportedEncodingException" namespace="" />
      </fault>
    </operation>
  </binding>
  <service name="rmt_ws">
    <port name="rmt_ws" binding="tns:rmt_wsBinding">
      <soap:address location="https://www1.gsis.gr/wsicispay/rmt_ws" />
    </port>
  </service>
</definitions>

Here is the call I make

rmt_ws client = new rmt_wsClient();
                using (rmt_wsClient rmt_wsClient = new rmt_wsClient())
                {

                    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

                    rmt_wsClient.ClientCredentials.UserName.UserName = UserName;
                    rmt_wsClient.ClientCredentials.UserName.Password = Password;

                    string messageToSend = "<wsTin>" + wsTin + "</wsTin><wsUser>" + wsUser + "</wsUser>" +
                        "<wsPswd>" + wsPswd + "</wsPswd><contain><bmrn>" + bmrn + "</bmrn><blrn>" + blrn +
                        "</blrn><bcnt>" + bcnt + "</bcnt><bafm>" + "bafm" + "</bafm></contain>";

                    rmt_wsClient.Open();

                    string responsed = rmt_wsClient.remittanceXml(messageToSend);
                    rtn = responsed;
                }

I saw in similar questions that there is something that I must change in app.config but everything I tried so far give me the same result.

Here is the part in my app.config in WcfClinet that I use now

<customBinding>
        <binding name="rmt_wsBinding1" >
          <textMessageEncoding messageVersion="Soap11" />
          <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
        </binding>
</customBinding>
 <client>
<endpoint address="https://www1.gsis.gr/wsicispay/rmt_ws" binding="customBinding"
        bindingConfiguration="rmt_wsBinding1" contract="IcisPayments.rmt_ws"
        name="rmt_ws" />
    </client>

and here is the app.config in my main program that I make the call

 <basicHttpBinding>
<binding name ="rmt_wsBinding1">
          <security mode="TransportWithMessageCredential" >
       <message clientCredentialType="UserName" />
    </security>
        </binding>
      </basicHttpBinding>
    <client>
 <endpoint address="https://www1.gsis.gr/wsicispay/rmt_ws" binding="basicHttpBinding" bindingConfiguration="rmt_wsBinding1" contract="IcisPayments.rmt_ws" name="rmt_ws" />
</client>

I don't know if I must change the app.config in my WcfClient or there is another error. This is my first time I use wsdl files and soap messages. I don't have any details on how the server that I try to connect works.

1 Answer 1

1

For anyone who has the same problem. The main problem is that even when I send the credentials it doesnt send them as header. I found the answer in my previous part of the question here thanks to H.G. Sandhagen

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.