String method =
"GetLtWorkSteps"
;
String company =
""
;
String userName =
""
;
String password =
""
;
String languageCode =
"en"
;
String countryCode =
"GB"
;
String typeId =
"13494"
;
String itemMpId =
"2450"
;
String bodyQualColId =
"0"
;
String korId =
"4"
;
String kindOfWorkTime =
"DecimalWorkHours"
;
String consumerId =
"13"
;
String soapProtocol = SOAPConstants.SOAP_1_1_PROTOCOL;
if
(useSoap12) {
soapProtocol = SOAPConstants.SOAP_1_2_PROTOCOL;
}
MessageFactory mf = MessageFactory.newInstance(soapProtocol);
SOAPMessage soapMessage = mf.createMessage();
if
(!useSoap12) {
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
mimeHeaders.addHeader(
"SOAPAction"
, namespace + method);
}
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
SOAPBody soapBody = soapEnvelope.getBody();
Name bodyName = soapEnvelope.createName(method,
""
, namespace);
SOAPBodyElement soapBodyElement = soapBody.addBodyElement(bodyName);
SOAPElement inputElement = soapBodyElement.addChildElement(
"input"
);
inputElement.addChildElement(
"CompanyName"
).addTextNode(company);
inputElement.addChildElement(
"UserName"
).addTextNode(userName);
inputElement.addChildElement(
"Password"
).addTextNode(password);
inputElement.addChildElement(
"LanguageCode"
).addTextNode(languageCode);
inputElement.addChildElement(
"CountryCode"
).addTextNode(countryCode);
inputElement.addChildElement(
"TypeId"
).addTextNode(typeId);
inputElement.addChildElement(
"ItemMpId"
).addTextNode(itemMpId);
inputElement.addChildElement(
"BodyQualColId"
).addTextNode(bodyQualColId);
inputElement.addChildElement(
"KorId"
).addTextNode(korId);
inputElement.addChildElement(
"KindOfWorkTime"
).addTextNode(kindOfWorkTime);
inputElement.addChildElement(
"ConsumerId"
).addTextNode(consumerId);
soapMessage.saveChanges();
SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = connectionFactory.createConnection();
SOAPMessage soapResponse = soapConnection.call(soapMessage, url);
soapConnection.close();
SOAPBody soapResponseBody = soapResponse.getSOAPBody();
SOAPFault soapFault = soapResponseBody.getFault();
if
(soapFault !=
null
) {
throw
new
SOAPException(soapFault.getFaultString());
}
System.out.println(
"WorkId | WorkText | QualColText"
);
System.out.println(
"--------------------------------"
);
NodeList list = soapResponseBody.getElementsByTagName(
"LtWorkPos"
);
for
(
int
i =
0
; i < list.getLength(); i++) {
Element language = (Element)list.item(i);
System.out.print(language.getElementsByTagName(
"WorkId"
).item(
0
).getTextContent());
System.out.print(
"\t|\t"
);
System.out.print(language.getElementsByTagName(
"WorkText"
).item(
0
).getTextContent());
System.out.print(
"\t|\t"
);
System.out.print(language.getElementsByTagName(
"QualColText"
).item(
0
).getTextContent());
System.out.println();
}