Highlighted
NewProgrammer Absent Member.
Absent Member.
423 views

How to solve validation error while creating Incident using java API

Hello all,I'm creating an incident using java code,But I keep getting validation error response.I can't understand whats wrong,even if I've specified all the fields currectly.Here is my code . Please Help

import org.apache.axis.client.Call;
import org.apache.axis.transport.http.HTTPConstants;

import com.hp.schemas.SM._7.CreateIncidentRequest;
import com.hp.schemas.SM._7.CreateIncidentResponse;
import com.hp.schemas.SM._7.IncidentInstanceType;
import com.hp.schemas.SM._7.IncidentInstanceTypeDescription;
import com.hp.schemas.SM._7.IncidentKeysType;
import com.hp.schemas.SM._7.IncidentManagement_PortType;
import com.hp.schemas.SM._7.IncidentManagement_Service;
import com.hp.schemas.SM._7.IncidentManagement_ServiceLocator;
import com.hp.schemas.SM._7.IncidentModelType;
import com.hp.schemas.SM._7.RetrieveIncidentListResponse;
import com.hp.schemas.SM._7.RetrieveIncidentRequest;
import com.hp.schemas.SM._7.Common.StringType;

public class TestCreateDev {
public static void main (String [] arg) throws Exception
{


IncidentManagement_Service service = new IncidentManagement_ServiceLocator();
IncidentManagement_PortType servicePort = service.getIncidentManagement();
CreateIncidentResponse response = new CreateIncidentResponse();
org.apache.axis.client.Stub clientStub = (org.apache.axis.client.Stub) servicePort;
try {

clientStub._setProperty(Call.USERNAME_PROPERTY, "user");
clientStub._setProperty(Call.PASSWORD_PROPERTY, "pass");
IncidentKeysType keys[] = new IncidentKeysType[1];
keys[0] = new IncidentKeysType();
StringType incident=new StringType();
incident.setType("String");
incident.set_value("IM001106137");
keys[0].setIncidentID(incident);
IncidentInstanceType instance=new IncidentInstanceType();
instance.setIncidentID(incident);
incident.set_value("incident");
instance.setCategory(incident);
incident.set_value("falcon");
instance.setOpenedBy(incident);
incident.set_value("1");
instance.setUrgency(incident);
incident.set_value("secret group");
instance.setAssignmentGroup(incident);
incident.set_value("secret");
instance.setAffectedCI(incident);
IncidentInstanceTypeDescription desc=new IncidentInstanceTypeDescription();
StringType[] description=new StringType[1];
description[0]=new StringType();
description[0].setType("String");
description[0].set_value("Test");
desc.setDescription(description);
desc.setType("Array");
instance.setDescription(desc);
incident.set_value("Sample");
instance.setTitle(incident);
incident.set_value("data");
instance.setArea(incident);
incident.set_value("incident");
instance.setSiteCategory(incident);
incident.set_value("data or file corrupted");
instance.setSubarea(incident);
incident.set_value("E-mail");
instance.setCeReportedVia(incident);
incident.set_value("Unacknowledged");
instance.setCeAcknowledgeStatus(incident);
incident.set_value("2");
instance.setImpact(incident);
IncidentModelType model=new IncidentModelType();
model.setInstance(instance);
model.setKeys(keys[0]);
CreateIncidentRequest request=new CreateIncidentRequest();
request.setAttachmentData(false);
request.setAttachmentInfo(false);
request.setIgnoreEmptyElements(true);
request.setModel(model);
response = servicePort.createIncident(request);

}
catch (Exception e) {
e.printStackTrace();
} finally {

clientStub._setProperty(HTTPConstants.REQUEST_HEADERS, HTTPConstants.HEADER_CONNECTION_CLOSE);

}
System.out.println(response.getStatus()+"---"+response.getMessage()+"---"+response.getModel().getMessages());
}

}

Tags (3)
0 Likes
1 Reply
TomPowe Acclaimed Contributor.
Acclaimed Contributor.

Re: How to solve validation error while creating Incident using java API

What's the error message or validation message that you are getting?

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.