web service authentication
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2013 01:14 AM
Hi,
I'm trying to implement a web_service and web_service_client in eclipse.
I want to insert an incident in incident's table using a web_service in eclipse.
From my instance I took the wsdl from url myinstance/incident.do?WSDL.
When I insert the .wsdl file in eclipse and create a web_service_client and use the operation "insert" I have this error:"Exception: (401)Unauthorized Message: (401)Unauthorized".
Now I want to authenticate with instance. In my opinion I should modify the .wsdl file and insert the authentication data (user, pass).
I searched a lot on web but I failed.
Can you help me? If you have already do this integration, can you post me an exemple so I can understand?
P.s
sorry for my broken English.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2013 07:37 AM
If your WSDL is protected from download by authentication, then simply download the WSDL locally and import that file using Eclipse.
When you attempt to do an insert (or any other operation), you'll need to set the basic authentication to a valid user with sufficient roles to do what you're wanting to do. That user should have the SOAP role and another role (such as ITIL) to insert incidents.
For your question on how to set the authentication credentials, this should be done in your JAVA code and requires NO modification of the WSDL. If you are using JAVA, you'll use logic like this:
HttpTransportProperties.Authenticator basicAuthentication = new HttpTransportProperties.Authenticator();
basicAuthentication.setUsername("admin");
basicAuthentication.setPassword("admin");
For more examples on this, take a look at this wiki article: http://wiki.servicenow.com/index.php?title=Java_Apache_Axis2_Web_Services_Client_Examples#Generate_your_Axis2_client_code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2013 08:16 AM
I already use the wsdl locally.
After I create the dynamic web project I create a new web service client with eclipse and I don't have to write java code because the client is created and started automatically using wsdl.
In wiki I've seen that the code that you gave me has to be inserted in client code but with eclipse I have not the client java code.
The client starts automatically and in fact I can invoke the methods but with error 401.
In particular, the get methods are ok, but the insert method give me error 401.
I created a simple web service (hello world) and using the corresponding .wsdl, I used the same procedure that I explained, and I have not problems.
I have problems now with the insert method for incident of servicenow.
In my opinion I have to modify the header of .wsdl file with authentication so that the web service client is created with authentication also if I don't see the client code.. Do you have any idea to do this?
This is my first time with service now and the first with web service. Whichever advice is accepted !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2013 08:16 AM
I already use the wsdl locally.
After I create the dynamic web project I create a new web service client with eclipse and I don't have to write java code because the client is created and started automatically using wsdl.
In wiki I've seen that the code that you gave me has to be inserted in client code but with eclipse I have not the client java code.
The client starts automatically and in fact I can invoke the methods but with error 401.
In particular, the get methods are ok, but the insert method give me error 401.
I created a simple web service (hello world) and using the corresponding .wsdl, I used the same procedure that I explained, and I have not problems.
I have problems now with the insert method for incident of servicenow.
In my opinion I have to modify the header of .wsdl file with authentication so that the web service client is created with authentication also if I don't see the client code.. Do you have any idea to do this?
This is my first time with service now and the first with web service. Whichever advice is accepted !!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2013 08:56 AM
That would not be correct. You do NOT need to modify the WSDL in any way. A 401 error is an authorization error. The only way to get past this is to authenticate (using JAVA) and set the basic auth credentials to a user who has the permissions to call a SOAP insert function (add the SOAP role to this user) as well as to insert into the target table.
Modifying the WSDL will not get you around this requirement in any way. The WSDL allows your Eclipse framework to know how to build the Java web service stubs. You still need to pass it (via code) the user credentials.
Hope this helps.