I have a SOAP-API with WSDL (to be exactly many WSDLs) and Basic-Auth with a lot of methods - via this API I can controll a software, therefore I need to validate and process the answers to decide which one to use next. I have a little example in php which is working:
$wsdl = 'https//.....wsdl';
$parameter = Array(
'login' => "un",
'password' => "pw",
'soap_version' => ...,
'exceptions' => True,
'trace' => 0
);
$client = new SOAPClient($wsdl, $parameter);
$request_copy = array(
'parameters' => array(
'some_id' => '123',
'some_value' => '...'
),
);
$response_copy = $client->__soapCall("copy", $request_copy);
In C# I found in the last days a lot of approaches 1. Parsing the information manually and sending manual post requests 2. Adding Service Reference to the wsdl (in visual studio)
I have an empty console application with added service reference - the namespace (calling it "ExampleNamespace") includes all relevant classes (for one wsdl), but I couln't find a way to send the request. I searched in all classes (API-methods are translated to classes in this ExampleNamespace if I'm getting it right) and could not find anything.
What I found is a class called like the added web reference (and no API method has that name) with an member ClientCredentials, which contains Username, so I have:
ExampleNamespace.FoundClass soap = new ExampleNamespace.FoundClass();
soap.ClientCredentials.UserName.UserName = "un";
soap.ClientCredentials.UserName.Password = "pw";
Also I found in some forum the hint, that the app.config has to contain something like the following to work with basic auth
<security mode="Transport" >
<transport clientCredentialType="Basic" realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
</security>
In summary: I can't find a (helpful) way to make a SOAP-requast in c#, I haven't found an example or anything really helpful. If anyone has a hint, an example, a solution or anything would be very helpful - there are a lot of threads on different forums, but nowhere is a good congregation of all necessary things
Thanks