The service enables you to create a new entity
Parameters:
Name
|
Type
|
Required
|
Description
|
User Name
|
string
|
Yes
|
The account's user name
|
Password
|
string
|
Yes
|
The account's password
|
The service returns LoginResult
which details will be used on the
SessionIdHeader for authentication
Java Code:
URL serviceEndPoint = null;
try {
serviceEndPoint = new URL(this.url);
} catch (MalformedURLException me) {
return "Error: Invalid url";
}
InwiseService s = new InwiseService(serviceEndPoint);
LoginResult logonResult = s.getInwiseServiceSoap().logon(this.userName, this.password);
if (logonResult.isIsSuccess() == false) {
return Utils.BuildErrorMessage(logonResult.getErrorDetails());
} else {
URL newEndpoint = null;
try {
newEndpoint = new URL(logonResult.getServiceUrl());
} catch (MalformedURLException me) {
return "Error: Invalid url";
}
InwiseService service = new InwiseService(newEndpoint, s.getServiceName());
HeaderHandlerResolver handlerResolver = new HeaderHandlerResolver();
service.setHandlerResolver(handlerResolver);
InwiseServiceSoap soapService = service.getInwiseServiceSoap();
Map<String, Object> context = ((BindingProvider) soapService).getRequestContext();
context.put("sessionId", logonResult.getSessionId());
Now we can call the "Login" operation for getting the session token.
For setting the new header, please check the code for creating the usual header
here with the following changed:
- Change the header name from "SecHeader" to "AuthIdentifier"
- Do not set SOAPElement "username" and SOAPElement "pass"
- Set a SOAPElement named "identifier" with the value of the token you recieved from
the service.
C# Code:
InwiseService.InwiseService
service = new InwiseService.InwiseService();
service.Url = this.url;
LoginResult logonResult
= service.Logon(this.userName,
this.password);
if (logonResult.IsSuccess ==
false)
{
return Utils.BuildErrorMessage(logonResult.ErrorDetails);
}
else
{
//// use the new service
url
service = new
InwiseService.InwiseService();
service.Url = logonResult.ServiceUrl;
//// prepare headers
service.SessionIdHeaderValue =
new SessionIdHeader()
{
SessionId = logonResult.SessionId
};
VB Code:
Dim service As New
InwiseService.InwiseService()
service.Url =
Me.url
Dim logonResult As LoginResult = service.Logon(Me.userName, Me.password)
If logonResult.IsSuccess = False
Then
Return Utils.BuildErrorMessage(logonResult.ErrorDetails)
Else
'' use the new service url
service.Url
= logonResult.ServiceUrl
'' prepare headers
service.SessionIdHeaderValue
= New SessionIdHeader()
With { _
.SessionId = logonResult.SessionId _
}
Raw Xml:
<?xml version="1.0"
encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Logon
xmlns="http://www.inwise.com/webservices/v2">
<userName>myUserName</userName>
<password>myPassword</password>
</Logon>
</soap:Body>
</soap:Envelope>
Response:
<?xml version="1.0"
encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LogonResponse
xmlns="http://www.inwise.com/webservices/v2">
<LogonResult>
<IsSuccess>true</IsSuccess>
<ErrorDetails>
<Code>Success</Code>
</ErrorDetails>
<SessionId>d93e413fff974291aed939d3e405bc91</SessionId>
<AccountId>0</AccountId>
<ServiceUrl>https://www.em-sender.com/InwiseService2.asmx</ServiceUrl>
<MinutesToLive>1200</MinutesToLive>
</LogonResult>
</LogonResponse>
</soap:Body>
</soap:Envelope>