Мне нужно использовать веб-службу от UltiPro на Java. Все примеры из UltiPro для C# (см. Ниже), и я не вижу, как перевести на Java.Создание Java-клиента для доступа к API-интерфейсу WSHTTPBINDING
Мои исследования показывают, что ключ WSHttpBinding.
документация UltiPro включает файл XML, что они говорят ...
Следующий код является XML пример аутентификации в данных UltiPro. Вы можете скопировать все содержимое и обновить значения в запросе. Пример ответа показывает, как будет отформатирован успешный ответ.
Я написал много веб-сервисов и RESTful программ раньше, но я застрял на этом.
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.ultipro.com/services/loginservice/ILoginService/Authenticate</a:Action>
<h:ClientAccessKey xmlns:h="http://www.ultipro.com/services/loginservice">CAK</h:ClientAccessKey>
<h:Password xmlns:h="http://www.ultipro.com/services/loginservice">PASSWORD</h:Password>
<h:UserAccessKey xmlns:h="http://www.ultipro.com/services/loginservice">USER API KEY</h:UserAccessKey>
<h:UserName xmlns:h="http://www.ultipro.com/services/loginservice">USERNAME</h:UserName>
</s:Header>
<s:Body>
<TokenRequest xmlns="http://www.ultipro.com/contracts" />
</s:Body>
</s:Envelope>
C# код:
namespace ConsoleSample
{
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using ConsoleSample.LoginService;
public class Program
{
internal static void Main(string[] args)
{
// Setup your user credentials:
const string UserName = "";
const string Password = "";
const string UserApiKey = "";
const string CustomerApiKey = "";
// Create a proxy to the login service:
var loginClient = new LoginServiceClient("WSHttpBinding_ILoginService");
try
{
// Submit the login request to authenticate the user:
string message;
string authenticationToken;
AuthenticationStatus loginRequest =
loginClient
.Authenticate(
CustomerApiKey,
Password,
UserApiKey,
UserName,
out message,
out authenticationToken);
if (loginRequest == AuthenticationStatus.Ok)
{
// User is authenticated and the authentication token is provided.
Console.WriteLine("User authentication successful.");
}
else
{
// User authentication has failed. Review the message for details.
Console.WriteLine("User authentication failed: " + message);
}
loginClient.Close();
Console.WriteLine("Press a key to exit...");
Console.ReadKey(true);
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex);
loginClient.Abort();
throw;
}
}
Вы не одиноки. Проблемы с Java ->. NET - самые худшие. – Matt1776
Я отказался от этого. Мы переходим на .NET, поэтому в любом случае это будет проще ... –