Iverbrauchen Web-Service-API-Authentifizierung SOAP in Java unter Verwendung
http://api.exigo.com/3.0/ExigoApi.asmx?WSDL
ein Java-Client für diesen Web-Service zu schreiben, ich versuche aber nicht in der Lage, es ist Authentication Header zu setzen in .NET-Umgebung gibt es eine Eigenschaft betreffenden ApiAuthentication Objekts Satz API Objekt wie folgt
//Set Authentication Header
ExigoApi api = new ExigoApi();
ApiAuthentication auth = new ApiAuthentication();
auth.Company = "company";
auth.LoginName = "name";
auth.Password = "password";
api.ApiAuthenticationValue = auth;
//Create request object
GetCustomersRequest req = new GetCustomersRequest();
//Specify which customer(s) we are getting
req.CustomerID = 1;
//Submit the request
GetCustomersResponse res = api.GetCustomers(req);
Console.WriteLine(res.Customers[0].CustomerID);
aber in Java kann ich diese Methode nicht
012 findenapi.ApiAuthenticationValue = auth;
dies ist der Code, den ich in Java geschrieben wirft aber Ausnahme
import com.exigo.api.*;
public class ExigoDemoService {
public static void main(String[] args) {
//Set Authentication Header
ExigoApi api = new ExigoApi();
ApiAuthentication auth = new ApiAuthentication();
auth.setCompany("company");
auth.setLoginName("name");
auth.setPassword("password");
//Create request object
GetCustomersRequest req = new GetCustomersRequest();
//Specify which customer(s) we are getting
req.setCustomerID(1);
//Submit the request
GetCustomersResponse res = api.getExigoApiSoap().getCustomers(req);
}
private static CreateCustomerResponse createCustomer(com.exigo.api.CreateCustomerRequest createCustomerRequest) {
com.exigo.api.ExigoApi service = new com.exigo.api.ExigoApi();
com.exigo.api.ExigoApiSoap port = service.getExigoApiSoap();
return port.createCustomer(createCustomerRequest);
}
private static GetCustomersResponse getCustomers(com.exigo.api.GetCustomersRequest getCustomersRequest) {
com.exigo.api.ExigoApi service = new com.exigo.api.ExigoApi();
com.exigo.api.ExigoApiSoap port = service.getExigoApiSoap();
return port.getCustomers(getCustomersRequest);
}
}
geworfen Exception
Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Authentication header missing!
Unable to Authenticate!
mir jemand helfen würde, ? Bitte, ich bin wirklich fest hier –