I am looking for sample java code to create a service-now ticket. I am using intellij and maven.

dashap
Giga Contributor

Morning,

I want to create as proof of concept a java class to allow me to create a ticket in service-now.Something that shows the connection, creation of the ticket, and closing with some error handling would be great. By the way, I see talk of ServiceNowStub.   What is that about?   Would that fit my need to do what I want to do?   How to I get this setup in intellij?

4 REPLIES 4

tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi David,



I have an idea this wiki article will be helpful:



Table API Java Examples - ServiceNow Wiki



edit:


specifically


3.2 POST



Best Regards



Tony


I have seen this article before. It seems to show connecting to an incident and I think adding a comment.   Not real sure what is going on there.   I was looking for something a little more robust like: Legacy:Web Services Axis2 Examples - ServiceNow Wiki


It looks like intellij has a web service option that I think will do what is shown with the option:



./wsdl2java.sh -uri https://<instance name>.service-now.com/incident.do?WSDL -o /glide/workspace/TestWebService/



I am not sure yet.   But you can see wit this I would be able to set things like:



nc.setAssigned_to("Christen Mitchell");


inc.setCategory("hardware");


inc.setPriority(BigInteger.ONE);


inc.setDescription("The WI_FI in the reception area is down");


inc.setCaller_id("Joe Employee");



This is more of what I would like to do.   Does anybody have some experience with using axis2 and creasting tickets?


tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi David,



Bad WSDL maybe related to elementFormDefault?


Java Apache Axis2 Web Services Client Examples - ServiceNow Wiki




edit:


The above is a guess, but perhaps a good look at the WSDL would be helpful?


There are online tools such as


Online WSDL Viewer and Validator


Plus SOAPUI for example can validate the WSDL



Best Regards



Tony