.Net コード (コンソール アプリケーション) から workday Web サービスを呼び出しようとしていました。
サービスリファレンスを追加しました。名前空間の詳細はすべて問題なく、名前空間内のすべてのクラスのメンバーとメソッドを取得できます。
メソッドを実行しようとすると、エラー (Client.AuthenticationErro(無効なユーザー名/パスワード) がスローされます。コードでクライアントの資格情報を既に提供しており、基本的なバインドを使用しています。私のコードと App.Config については、以下を参照してください。ファイルですが、Web サービスの呼び出しに SOAP UI を使用している場合、すべて正常に動作します。
class Demo
{
static void GetPhoto(string EmployeeID)
{
HR.Employee_Image_GetType EmpImageGetType = new HR.Employee_Image_GetType();
EmpImageGetType.version = "v17";
HR.IDType EmpIDType = new HR.IDType();
EmpIDType.Value = EmployeeID;
HR.External_Integration_ID_Reference_DataType IDRef = new HR.External_Integration_ID_Reference_DataType();
IDRef.ID = EmpIDType;
HR.Employee_ReferenceType[] EmpRefArray = new HR.Employee_ReferenceType[1];
HR.Employee_ReferenceType Empref = new HR.Employee_ReferenceType();
Empref.Integration_ID_Reference = IDRef;
EmpRefArray[0] = Empref;
EmpImageGetType.Employee_Reference = EmpRefArray;
var binding=new BasicHttpBinding(BasicHttpSecurityMode.Transport);
binding.Security.Transport.ClientCredentialType=HttpClientCredentialType.Basic;
Human_ResourcesPortClient proxy = new Human_ResourcesPortClient((System.ServiceModel.Channels.Binding)binding, new EndpointAddress("https://impl-cc.workday.com/ccx/service/amat1/Human_Resources/v17?wsdl"));
proxy.ClientCredentials.HttpDigest.ClientCredential.UserName = "XXXXXX@XXXYY";
proxy.ClientCredentials.HttpDigest.ClientCredential.Password = "xxxx";
proxy.ChannelFactory.Credentials.HttpDigest.ClientCredential.UserName = "XXXXXX@XXXYY";
proxy.ChannelFactory.Credentials.HttpDigest.ClientCredential.Password = "xxxx";
proxy.ClientCredentials.UserName.UserName = "XXXXXX@XXXYY";
proxy.ClientCredentials.UserName.Password = "xxxxx";
try
{
HR.Employee_ImageType EmpImageType = proxy.Get_Employee_Image(EmpImageGetType);
Console.WriteLine("Success");
}
catch (Exception exp)
{
Console.WriteLine("Exception:" +exp.Message +exp.StackTrace);
}
Console.ReadLine();
}
public static void BypassCertificateError()
{ ServicePointManager.ServerCertificateValidationCallback =
delegate(Object sender1, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
}
}
- App.Config
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Human_ResourcesBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Basic" proxyCredentialType="Basic"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="Human_ResourcesBinding1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Basic" proxyCredentialType="Basic"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://impl-cc.workday.com/ccx/service/amat1/Human_Resources/v17"
binding="basicHttpBinding" bindingConfiguration="Human_ResourcesBinding"
contract="HR.Human_ResourcesPort" name="Human_Resources" />
</client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>
**
誰でも私を助けてもらえますか?