Authorization - WSDL File, Proxy class in C#

Markus Freitag 3,786 Reputation points
2022-01-17T10:01:04.123+00:00

Hello,

I have received a WSDL file from a customer. With this I have created a proxy class via WSDL. --> IO
The server must be connected via Authorization.
I don't see anything there. How can I make the connection via Authorization?
The proxy class is quite complex. I need only 2 requests.

Is there any way I can best create the request. There is no support from the customer.

The alternative would be to create it myself via XDocument, which I am not in favor of.

 private void btnOrderData_Click(object sender, EventArgs e)
        {
            using (PDXCSMEService danS = new PDXCSMEService())
            {
                //danS .Url = "";

//  danS.Auto....???
Internet Information Services
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,316 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,288 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,385 questions
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 26,166 Reputation points
    2022-01-20T14:44:58.337+00:00

    Not work, no Url inside the proxy class. Is my call wrong?

    I'm guessing you did not thoroughly read the svcutil.exe reference documentation which clearly indicates the svcutil.exe creates a output.config file. The config file contains the URL as well as other configurations. Either rename output.config to app.config and place the file in the application root or copy the appropriate nodes to you app.config file.

    Keep in mind, I'm just guessing what's wrong as I do not have the wsdl, service documentation, and you've provide very little code. Still the service owners are your best option. Otherwise, maybe hire someone that can help you.

    Example configuration that uses HTTP. Change to Transport security for HTTPS.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="WebServiceSoap">
         <security mode="TransportCredentialOnly">
         <transport clientCredentialType="Basic" />
         </security>
         </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost/WebService/WebService.asmx"
                    binding="basicHttpBinding" bindingConfiguration="WebServiceSoap"
                    contract="WebServiceSoap" name="WebServiceSoap" />
            </client>
        </system.serviceModel>
    </configuration>
    

    Implementation

    static void Main(string[] args)
    {
        WebServiceSoapClient client = new WebServiceSoapClient("WebServiceSoap");
    
        client.ClientCredentials.UserName.UserName = "username";
        client.ClientCredentials.UserName.Password = "password!";
    
        string resposne = client.HelloWorld();
        Console.WriteLine(resposne);
    }
    
    1 person found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. Limitless Technology 39,436 Reputation points
    2022-01-24T09:15:15.557+00:00

    Hi there,

    Basic authentication is supported by specifying a policy in the WSDL. A basic authentication policy can be added to the WSDL either manually or by using the WS-Policy Attachment window accessed from CASA and provided through Tango (WSIT). A basic authentication policy is specified at the root level of the WSDL and a reference to the policy is made in the WSDL Port type section, binding the policy to the endpoint.


    --If the reply is helpful, please Upvote and Accept it as an answer--

    1 person found this answer helpful.