Program.cs
BasicHttpsBinding binding = new BasicHttpsBinding();
binding.Name = "DocumentoPort";
binding.Security.Mode = BasicHttpsSecurityMode.Transport;
EndpointAddress endpoint = new EndpointAddress("https://xxx.xxx.xxx/webserviceproxy/se/ws/dc_ws.php");
DocumentoPortTypeClient doc = new DocumentoPortTypeClient(binding, endpoint);
doc.ClientCredentials.UserName.UserName = "xxx";
doc.ClientCredentials.UserName.Password = @"xxx";
var methods = doc.GetType().UnderlyingSystemType.GetMethods();
foreach (var t in methods)
{
Console.WriteLine(t.Name);
}
string idcategory = "xxxxx";
string iddocument = "xxxxx";
string title = "xxxxx";
string dsresume = "";
string iduser = "";
string dtdocument = "";
int fgmodel = 0;
string attributes = "";
var participants = new participantsData[5];
var file = new eletronicFile[3];
var keyword = new keyWordData[2];
string resp = doc.newDocument(idcategory, iddocument, title, dsresume, dtdocument, attributes, iduser, participants, fgmodel, file, keyword);
var tt = getRespAsync2(doc);
Console.WriteLine(tt);
public static async System.Threading.Tasks.Task getRespAsync2(DocumentoPortTypeClient doc)
{
string idcategory = "xxxx";
string iddocument = "xxxx";
string title = "xxxx";
string dsresume = "";
string dtdocument = "";
string iduser = "";
int fgmodel = 0;
string attributes = "";
var participants = new participantsData[5];
var file = new eletronicFile[3];
var keyword = new keyWordData[2];
newDocumentResponse resp= await doc.newDocumentAsync(idcategory,iddocument,title,dsresume,dtdocument,attributes,iduser,participants,fgmodel,file,keyword);
}
App.Config
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<client>
<endpoint address="https://xxx.xxx.xxx/webserviceproxy/se/ws/dc_ws.php"
binding="basicHttpBinding" bindingConfiguration="DocumentoBinding"
contract="SoftexpertDocument.DocumentoPortType" name="DocumentoPort" />
</client>
<bindings>
<basicHttpBinding>
<binding name="DocumentoBinding">
<security mode="Transport" />
</binding>
<binding name="DocumentoBinding1" />
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
в сервисе есть 2 отдельные функции, но они выполняют ту же работу.
- newDocument: ошибка, выданная функцией:
System.ServiceModel.Security.MessageSecurityException: 'The HTTP request was forbidden with client authentication scheme 'Anonymous'.'
Inner Exception
WebException: The remote server returned an error: (403) Forbidden.
2.newDocumentAsync не выдает никаких ошибок. Но это не работает.
Я думаю, что не могу правильно настроить службу.
Тест SoapUI -> использовать аутентификацию basi c и проверять аутентификацию с преимущественной проверкой.
Выполнить
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:document">
<soapenv:Header/>
<soapenv:Body>
<urn:newDocument>
<urn:idcategory>xxxx</urn:idcategory>
<urn:iddocument>xxxx</urn:iddocument>
<urn:title>xxxx</urn:title>
<urn:dsresume></urn:dsresume>
<urn:dtdocument></urn:dtdocument>
<urn:attributes></urn:attributes>
<urn:iduser></urn:iduser>
<urn:participants>
</urn:participants>
<urn:fgmodel></urn:fgmodel>
<urn:file></urn:file>
<urn:keyword></urn:keyword>
</urn:newDocument>
</soapenv:Body>
</soapenv:Envelope>
Работать.