我需要将结果放入每个相应的结果属性中(请参见下面的URL中的图像)。但没有运气。你能帮我我所缺少的吗?binary search
SupportRequestSoapImpl .java
公共类SupportRequestSoapImpl {
public SupportRequestSoapImpl() {
}
@WebResult(name = "TicketStatusResponse", partName = "parameters",
targetNamespace = "http://mncc.navy.mil/MnccMnpTicket")
@WebMethod(operationName = "GetTicketStatus")
public TicketStatusResponse getTicketStatus(@WebParam(name = "TicketStatusRequest", partName = "parameters",
targetNamespace = "http://mncc.navy.mil/MnccMnpTicket")
TicketStatusRequest parameters) {
TicketStatusResponse response = new TicketStatusResponse();
ObjectFactory factory = new ObjectFactory();
Context ctx = null;
Connection conn = null;
Hashtable<String, String> ht = new Hashtable<String, String>();
List<TicketStatusDetails> resultList = new ArrayList<TicketStatusDetails>();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost:7101");
try {
ctx = new InitialContext(ht);
DataSource ds = (DataSource) ctx.lookup("jdbc/AjayOrcl");
conn = ds.getConnection();
final String typeName = "xxTicketStatusRec";
final String typeTableName = "xxTicketStatusTbl";
final StructDescriptor structDescriptor = StructDescriptor.createDescriptor(typeName.toUpperCase(), conn);
final ResultSetMetaData metaData = structDescriptor.getMetaData();
String sql = "Begin xxSRTicketsPkg.ticketStatus(?,?); End;";
CallableStatement cs = null;
cs = conn.prepareCall(sql);
cs.setString(1, parameters.getDodId());
cs.registerOutParameter(2, Types.ARRAY, typeTableName.toUpperCase());
cs.execute();
TicketStatusDetails tkctDtls = new TicketStatusDetails();
Object[] data = (Object[]) ((Array) cs.getObject(2)).getArray();
if (data != null) {
for (int i = 0; i < data.length - 1; i++) {
Object tmp = data[i];
Struct row = (Struct) tmp;
int index = 1;
for (Object attribute : row.getAttributes()) {
if (metaData.getColumnName(index).equalsIgnoreCase("TICKETNUMBER")) {
System.out.println("Ticket Number: " + attribute);
tkctDtls.getTicketNumberAndCaseTypeAndCaseSubtype()
.add(factory.createTicketStatusDetailsCaseSubtype(String.valueOf(attribute)));
}
if (metaData.getColumnName(index).equalsIgnoreCase("CASESUBTYPE")) {
System.out.println("Case Sub Type: " + attribute);
tkctDtls.getTicketNumberAndCaseTypeAndCaseSubtype()
.add(factory.createTicketStatusDetailsCaseSubtype((String) attribute));
}
if (metaData.getColumnName(index).equalsIgnoreCase("OPENDATE")) {
System.out.println("Open Date: " + attribute);
tkctDtls.getTicketNumberAndCaseTypeAndCaseSubtype()
.add(factory.createTicketStatusDetailsCaseSubtype(timestampAsString((Timestamp) attribute)));
}
if (metaData.getColumnName(index).equalsIgnoreCase("SUMMARY")) {
System.out.println("Summary: " + attribute);
tkctDtls.getTicketNumberAndCaseTypeAndCaseSubtype()
.add(factory.createTicketStatusDetailsCaseSubtype((String) attribute));
}
if (metaData.getColumnName(index).equalsIgnoreCase("CASETYPE")) {
System.out.println("Case Type: " + attribute);
tkctDtls.getTicketNumberAndCaseTypeAndCaseSubtype()
.add(factory.createTicketStatusDetailsCaseSubtype((String) attribute));
}
if (metaData.getColumnName(index).equalsIgnoreCase("CLOSEDATE")) {
System.out.println("Close Date: " + attribute);
if (attribute != null) {
tkctDtls.getTicketNumberAndCaseTypeAndCaseSubtype()
.add(factory.createTicketStatusDetailsCaseSubtype(timestampAsString((Timestamp) attribute)));
}
}
if (metaData.getColumnName(index).equalsIgnoreCase("RESOLUTION")) {
System.out.println("Resolution: " + attribute);
tkctDtls.getTicketNumberAndCaseTypeAndCaseSubtype()
.add(factory.createTicketStatusDetailsCaseSubtype((String) attribute));
}
++index;
}
resultList.add(tkctDtls);
}
response.getTicketDetails().addAll(resultList);
}
}
catch (NamingException e) {
e.printStackTrace();
}
catch (SQLException e) {
e.printStackTrace();
}
finally {
try {
conn.close();
ctx.close();
} catch (Exception e) {
e.printStackTrace();
}
} // finally
return response;
}
public static String timestampAsString(Timestamp timestamp) {
return DateTimeFormat.forPattern("ddMMyyyy").print(timestamp.getTime());
}
}
TicketStatusResponse.java
@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name =“”,propOrder = { “ ticketDetails”, “错误消息” }) @XmlRootElement(name =“ TicketStatusResponse”)
公共类TicketStatusResponse {
protected List<TicketStatusDetails> ticketDetails;
protected String errorMsg;
/**
* Gets the value of the ticketDetails property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the ticketDetails property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTicketDetails().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link TicketStatusDetails }
*
*
*/
public List<TicketStatusDetails> getTicketDetails() {
if (ticketDetails == null) {
ticketDetails = new ArrayList<TicketStatusDetails>();
}
return this.ticketDetails;
}
/**
* Gets the value of the errorMsg property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getErrorMsg() {
return errorMsg;
}
/**
* Sets the value of the errorMsg property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setErrorMsg(String value) {
this.errorMsg = value;
}
}
TicketStatusDetails.java
@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name =“ TicketStatusDetails”,propOrder = { “ ticketNumberAndCaseTypeAndCaseSubtype” })
公共类TicketStatusDetails {
@XmlElementRefs({
@XmlElementRef(name = "ticketNumber", namespace = "http://mncc.navy.mil/MnccMnpTicket", type = JAXBElement.class),
@XmlElementRef(name = "caseSubtype", namespace = "http://mncc.navy.mil/MnccMnpTicket", type = JAXBElement.class),
@XmlElementRef(name = "creationDate", namespace = "http://mncc.navy.mil/MnccMnpTicket", type = JAXBElement.class),
@XmlElementRef(name = "summary", namespace = "http://mncc.navy.mil/MnccMnpTicket", type = JAXBElement.class),
@XmlElementRef(name = "caseType", namespace = "http://mncc.navy.mil/MnccMnpTicket", type = JAXBElement.class),
@XmlElementRef(name = "closedDate", namespace = "http://mncc.navy.mil/MnccMnpTicket", type = JAXBElement.class),
@XmlElementRef(name = "resolution", namespace = "http://mncc.navy.mil/MnccMnpTicket", type = JAXBElement.class)
})
protected List<JAXBElement<?>> ticketNumberAndCaseTypeAndCaseSubtype;
/**
* Gets the value of the ticketNumberAndCaseTypeAndCaseSubtype property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the ticketNumberAndCaseTypeAndCaseSubtype property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTicketNumberAndCaseTypeAndCaseSubtype().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link XMLGregorianCalendar }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link XMLGregorianCalendar }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*
*/
public List<JAXBElement<?>> getTicketNumberAndCaseTypeAndCaseSubtype() {
if (ticketNumberAndCaseTypeAndCaseSubtype == null) {
ticketNumberAndCaseTypeAndCaseSubtype = new ArrayList<JAXBElement<?>>();
}
return this.ticketNumberAndCaseTypeAndCaseSubtype;
}
}