String method =
"GetVtMakeList"
;
String company =
""
;
String userName =
""
;
String password =
""
;
String languageCode =
"en"
;
String countryCode =
"GB"
;
String moduleFilter =
"Lt"
;
String rangeNameFilter =
"A3"
;
String showBike =
"false"
;
String showCar =
"true"
;
String showTruck =
"false"
;
String typeNameFilter =
"2.0 TDI"
;
String addInfoKeyId_1 =
"3"
;
String addInfoKeyFilterValue_1 =
"2005"
;
String addInfoKeyId_2 =
"5"
;
String addInfoKeyFilterValue_2 =
"100"
;
String addInfoKeyId_3 =
"6"
;
String addInfoKeyFilterValue_3 =
"1968"
;
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(
"ModuleFilter"
).addTextNode(moduleFilter);
inputElement.addChildElement(
"RangeNameFilter"
).addTextNode(rangeNameFilter);
inputElement.addChildElement(
"ShowBike"
).addTextNode(showBike);
inputElement.addChildElement(
"ShowCar"
).addTextNode(showCar);
inputElement.addChildElement(
"ShowTruck"
).addTextNode(showTruck);
inputElement.addChildElement(
"TypeNameFilter"
).addTextNode(typeNameFilter);
SOAPElement addInfoKeyFilterElement = inputElement.addChildElement(
"AddInfoKeyFilter"
);
SOAPElement addInfoKeyFilterParameterElement_1 = addInfoKeyFilterElement.addChildElement(
"AddInfoKeyFilterParameter"
);
addInfoKeyFilterParameterElement_1.addChildElement(
"AddInfoKeyId"
).addTextNode(addInfoKeyId_1);
addInfoKeyFilterParameterElement_1.addChildElement(
"AddInfoKeyFilterValue"
).addTextNode(addInfoKeyFilterValue_1);
SOAPElement addInfoKeyFilterParameterElement_2 = addInfoKeyFilterElement.addChildElement(
"AddInfoKeyFilterParameter"
);
addInfoKeyFilterParameterElement_2.addChildElement(
"AddInfoKeyId"
).addTextNode(addInfoKeyId_2);
addInfoKeyFilterParameterElement_2.addChildElement(
"AddInfoKeyFilterValue"
).addTextNode(addInfoKeyFilterValue_2);
SOAPElement addInfoKeyFilterParameterElement_3 = addInfoKeyFilterElement.addChildElement(
"AddInfoKeyFilterParameter"
);
addInfoKeyFilterParameterElement_3.addChildElement(
"AddInfoKeyId"
).addTextNode(addInfoKeyId_3);
addInfoKeyFilterParameterElement_3.addChildElement(
"AddInfoKeyFilterValue"
).addTextNode(addInfoKeyFilterValue_3);
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(
"MakeId | MakeName"
);
System.out.println(
"-------------------"
);
NodeList list = soapResponseBody.getElementsByTagName(
"VtMake"
);
for
(
int
i =
0
; i < list.getLength(); i++) {
Element language = (Element)list.item(i);
System.out.print(language.getElementsByTagName(
"MakeId"
).item(
0
).getTextContent());
System.out.print(
"\t|\t"
);
System.out.print(language.getElementsByTagName(
"MakeName"
).item(
0
).getTextContent());
System.out.println();
}