SC web services (1650 Views)
Reply
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 1 of 26 (1,650 Views)
Accepted Solution

SC web services

Hi everyone, my client asked me to integrate one of their applications with servicecenter through Web Services, I know SC is capable to publish columns of a specific table in order to get web services.

Is this right?, what should I look first in order to publish this webservices? Some steps would be appreciate it.

Regards

Alfredo
Frequent Advisor
David Ramm
Posts: 48
Registered: ‎03-26-2007
Message 2 of 26 (1,654 Views)

Re: SC web services

We've been using v6.x web services for all our interfaces to HP SC data. Here're some pointers that I think will help get you started assuming you are using v6.x

1) You need a SOAP API licence to use them (Utilities -> Administration -> Version Information -> Licenced Products -> SOAP API)

2) Extaccess records define what tables (files), columns, datatypes, web methods are exposed through the web service (Utilities -> Tools -> Web Services -> External Access). If a table is not exposed then creating one of these records will expose it. Have a look at some existing records in External Access. An exmaple WSDL out-of-the-box for the cm3r table can be seen at: http://localhost:12670/ChangeManagement.wsdl

3) When using a HP SC web service, a username and password needs to be supplied. The user is a HP SC operator with atleast the capability word of SOAP API or a capability word that inherits it.

4) Have a look at the attached document: Web Services With ServiceCenter Best Practices.pdf

cheers,
David
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 3 of 26 (1,654 Views)

Re: SC web services

Hi David, thanks for the info.

I checked and I have access to SOAP API module, also my operator have SOAP API capability word and I modify the ChangeManagement extaccess file (I just wanted tu publish some fields of cm3r table).

The ChangeManagement wsdl file is generate correctly.

But now I dont know what to do. What else do I need to start using the web services? I need to create a web services using .NET and the wsdl file? , or the method are built dinamically? How can I call those services?

I need a external application consume this web services.
Advisor
nobody13
Posts: 25
Registered: ‎02-11-2008
Message 4 of 26 (1,654 Views)

Re: SC web services

Alfredo,
Consuming WebServices is done through a custom application written in a WS supported language (C#, java, python etc). The SC 6.x server comes with a very limited example, but it is enough to get a competent programmer started. Check out \webservices\sample
There are two folders, DotNetSample and AxisSample for C# and Java respectively. Each also contains a readme file on how to compile and run the application.
Have fun.
-- Travis
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 5 of 26 (1,654 Views)

Re: SC web services

Hi Travis, thanks for the tips, I haven't developed in VB.net in a long time, well I think is about time to undust my programmer skills again, I hope you can give me a hand if I get stuck with something.

Regards

Alfredo
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 6 of 26 (1,654 Views)

Re: SC web services

By the way is someone was web services that can share to get helps of how to achieve this will be appreciated

Alfredo
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 7 of 26 (1,654 Views)

Re: SC web services

By the way is someone has web services that can share to get helps of how to achieve this will be appreciated

Alfredo
Frequent Advisor
David Ramm
Posts: 48
Registered: ‎03-26-2007
Message 8 of 26 (1,654 Views)

Re: SC web services

I've used both C# (Visual Studio .NET) and Java (IRAD) and they provide wizards to do the hard work. Just provide it the WSDL and it'll generate all the code needed. Then it's usually just a few lines of code to consume the web service. VB.net would be along the same lines as c#.

In Visual Studio right click the project -> Add Web Reference -> enter the URL \ WSDL. Both Java and c#/VB provide methods to specify a username and password before calling the webservice.

Obviously if you change the extaccess in HP SC it'll change the WSDL so will need to regenerate the code.
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 9 of 26 (1,654 Views)

Re: SC web services

Hi David, I add the webreference to my web service. Visual Studio created all the methods but I still have problem calling the createchangerequest method. I was assuming the method will created the change number, I just defined the category of the change as follow:

_
Public Function InsertarCambio(ByVal Categoria As String) As Integer

If Categoria <> Nothing Then

Dim ChangeCat As New StringType
ChangeCat.Value = Categoria

Dim objCat As New ChangeInstanceTypeHeader
objCat.Category = ChangeCat

Dim objModel As New ChangeModelType
objModel.instance.header = objCat

Dim objCrearCambio As New ChangeManagement.CreateChangeRequest
objCrearCambio.ignoreEmptyElements = True
objCrearCambio.model = objModel


End If

End Function

But I dont find the in the changemanagement reference to execute the create change method. Could you give me a hand on this David? If you have msn or a mail where I can ask you some questions will be great.
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 10 of 26 (1,654 Views)

Re: SC web services

Hi David, I add the webreference to my web service. Visual Studio created all the methods but I still have problem calling the createchangerequest method. I was assuming the method will created the change number, I just defined the category of the change as follow:

WebMethod() _
Public Function InsertarCambio(ByVal Categoria As String) As Integer


Dim ChangeCat As New StringType
ChangeCat.Value = Categoria

Dim objCat As New ChangeInstanceTypeHeader
objCat.Category = ChangeCat

Dim objModel As New ChangeModelType
objModel.instance.header = objCat

Dim objCrearCambio As New ChangeManagement.CreateChangeRequest
objCrearCambio.ignoreEmptyElements = True
objCrearCambio.model = objModel


End Function

But I dont find the in the changemanagement reference to execute the create change method. Could you give me a hand on this David? If you have msn or a mail where I can ask you some questions will be great.
Frequent Advisor
David Ramm
Posts: 48
Registered: ‎03-26-2007
Message 11 of 26 (1,642 Views)

Re: SC web services

Alfredo,

I found my c# example so the VB.net would be equivalent. I called my web reference SCentre. The fields you'd populate are most likely different, based on your HP SC extaccess record.

//create the proxy
SCentre.ChangeManagement CM = new SCentre.ChangeManagement();
CM.UseDefaultCredentials = false;
CM.PreAuthenticate = true;
CM.UnsafeAuthenticatedConnectionSharing = false;

//set up the credentials
System.Net.NetworkCredential nc = new System.Net.NetworkCredential("admin", "qwerty01*");
CM.Credentials = nc;

//create the request
SCentre.CreateChangeRequest ccr = new SCentre.CreateChangeRequest();

//populate details for the change
ccr.model = new SCentre.ChangeModelType();
ccr.model.instance = new SCentre.ChangeInstanceType();

//category
ccr.model.instance.header = new SCentre.ChangeInstanceTypeHeader();
ccr.model.instance.header.Category = new SCentre.StringType();
ccr.model.instance.header.Category.Value = "JPTest";

//description
ccr.model.instance.descriptionstructure = new SCentre.ChangeInstanceTypeDescriptionstructure();
ccr.model.instance.descriptionstructure.Description = new SCentre.ChangeInstanceTypeDescriptionstructureDescription();
ccr.model.instance.descriptionstructure.Description.Description = new SCentre.StringType[1];
ccr.model.instance.descriptionstructure.Description.Description[0] = new SCentre.StringType();
ccr.model.instance.descriptionstructure.Description.Description[0].Value = "My Desc";

//call the web method
SCentre.CreateChangeResponse response = CM.CreateChange(ccr);

String result = response.message + " Change number is: " + response.model.instance.header.ChangeNumber.Value;

If you like, you can try david.ramm@tenix.com

cheers,
David
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 12 of 26 (1,642 Views)

Re: SC web services

Hi David, thanks for the example let me do some testing and I´ll keep you inform.

Thanks!!!

Alfredo
Advisor
nobody13
Posts: 25
Registered: ‎02-11-2008
Message 13 of 26 (1,642 Views)

Re: SC web services

David,
When I was experimenting with the OOB examples, we found that a pid was active on the server after the initial request as long as the .exe was running.
I notice you don't use the CredentialCache as the OOB examples do. Does your code keep an active pid on the SC server after the request/response?
-- T
Frequent Advisor
David Ramm
Posts: 48
Registered: ‎03-26-2007
Message 14 of 26 (1,642 Views)

Re: SC web services

Do you mean you are sending the request but not getting a response back, i.e. hanging? When you check the processes for HP SC server, you are seeing an extra process? Have you looked in the sc.log for info on what the server is doing?

I'm not quite sure what you are saying the problem is? You wouldn't want a new pid hanging around, not ending everytime you call a web service - is that what is happening?

cheers,
David
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 15 of 26 (1,642 Views)

Re: SC web services

Hi David, I was able to replicate your code with some minors tweaks but at the time of the last line were the response method is called I got an error about the SOAP Header, do you know why this occur?

Error:

System.Web.Services.Protocols.SoapHeaderException: Exception of type 'System.Web.Services.Protocols.SoapHeaderException' was thrown. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at SCentre.ChangeManagement.CreateChange(CreateChangeRequest CreateChangeRequest) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web services sc-pcs\76cd14c7\c59a77f6\App_WebReferences.u79tw9ju.0.cs:line 242 at Service.CrearCambio(String Categoria) in D:\Data Clientes\Telecom\Web Services SC-PCS\App_Code\Service.vb:line 47


Code:

_
Public Function CrearCambio(ByVal Categoria As String) As String

Dim ChangeID As String = Nothing

Dim CM As New SCentre.ChangeManagement()
CM.UseDefaultCredentials = False
CM.PreAuthenticate = True
CM.UnsafeAuthenticatedConnectionSharing = False

Dim nc As New NetworkCredential("WebService_User", "VisualStudio")
CM.Credentials = nc

'Creando la solicitud de creacion de ticket
Dim ccr As New SCentre.CreateChangeRequest()

'Llenar detalles del cambio
ccr.model = New SCentre.ChangeModelType()
ccr.model.instance = New SCentre.ChangeInstanceType()
ccr.ignoreEmptyElements = True

'Categoria
ccr.model.instance.header = New SCentre.ChangeInstanceTypeHeader()
ccr.model.instance.header.Category = New SCentre.StringType()
ccr.model.instance.header.Category.Value = Categoria

'Llamando al metodo web
Try
Dim response As SCentre.CreateChangeResponse
response = CM.CreateChange(ccr)
ChangeID = response.model.instance.header.ChangeNumber.Value
Catch ex As Exception
ChangeID = ex.ToString()
End Try

Return ChangeID

End Function


Thanks in advance for any help.

Regards

Alfredo
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 16 of 26 (1,642 Views)

Re: SC web services

if found this on the sc.log

380( 3420) 02/26/2008 12:54:10 RTE W Authentication failure - No "Authorization: Basic" header was supplied, or it contained a zero-length userid
380( 3420) 02/26/2008 12:54:10 RTE W Exception occurred for method Create and XML request
Microinformatica

380( 3420) 02/26/2008 12:54:10 RTE W soap_serve - Caught XML API exception scxmlapi(20) - Authentication failure
380( 3420) 02/26/2008 12:54:10 RTE W Sending 401 Not Authorized challenge
380( 3420) 02/26/2008 12:54:10 RTE I User WebService_User has logged in and is using a Named license (2 out of a maximum 20)
380( 3420) 02/26/2008 12:54:10 RTE W Exception occurred for method Create and XML request
Microinformatica

380( 3420) 02/26/2008 12:54:10 RTE W soap_serve - Caught XML API exception scxmlapi(4) - Documento XML faltante o no válido
380( 3420) 02/26/2008 12:54:10 RTE W Sending SOAP fault
380( 3420) 02/26/2008 12:54:10 RTE I SOAP server stopping...
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 17 of 26 (1,642 Views)

Re: SC web services

I had to add the credential cache in order to define the system type "Basic" as the SC example do. These cache credentials are add with the network credential I defined first but when those chache credentials are assigned to the changemanagement.credential attribute the username and password dfefined in the network credential object are lost as show in the picture.

Is this normal?, or is something wrong in my code?

Now when trying to execute the web services I get the 401: unauthorized error message.
Occasional Visitor
Josef Singer
Posts: 3
Registered: ‎03-19-2008
Message 18 of 26 (1,642 Views)

Re: SC web services

I am also trying to integrate with Service Center using web services. I know there are similar postings, but hopefully this will be obvious for someone who has done this. I am able to query the wsdl at http://servername:12670/ChangeManagement.wsdl, and I can successfully query exisiting tickets. However, my attempts to create new tickets fail, with error scxmlapi(19) - Doc Engine call failed with -1. I have the "Best Practices for Publishing and Consumng Web Services with ServiceCenter" document, which mentions this on page 33, but I don't have a clue what to do about it. Any suggestions? Also, I assume that I should be invoking the CreateChange operation. What value should I pass in for Change Number? I assume that Service Center should be generating the ticket number? Thanks for your help.
Josef
Honored Contributor
Lars Detmers
Posts: 1,430
Registered: ‎10-04-2006
Message 19 of 26 (1,642 Views)

Re: SC web services

Hi,

what version are you on?
I suggest that you use SOAPSonar to create a ticket manually. (You need to enter authentication (for ex: user=falcan and password). This helped me to find out what is needed.

The ticket is created in a similar way as if you do it in the client, so ticket number is created. Depending on the mandatory fields you minimum need to give a category...

HTH

Lars
Occasional Visitor
Josef Singer
Posts: 3
Registered: ‎03-19-2008
Message 20 of 26 (1,642 Views)

Re: SC web services

Hi:
I am running Service Center 6.1.1. I was using soapUI, but I will try SOAP Sonar as well. The wsdl seems very vague about what is required, and the format it should be in. I see that 'Category' was one of those referred to as 'optional', but I am sure its not (subcategory is also requried in the web UI). Also, when I am doing a CreateChange, do I just leave ChangeNumber section out, leave it blank, or something else?
Thanks,
Josef
Honored Contributor
Lars Detmers
Posts: 1,430
Registered: ‎10-04-2006
Message 21 of 26 (1,640 Views)

Re: SC web services

Hi,

you leave change number out. Did you test it with OOB SC6.1 Change Managment (if yes, what category)?

Greets from Munich

Lars
Honored Contributor
Lars Detmers
Posts: 1,430
Registered: ‎10-04-2006
Message 22 of 26 (1,640 Views)

Re: SC web services

Hi,

I just tested it with my SM7, I was able to create a change (only needed category and one new mandatory field I have in my system).

It always depends on the URL you use. In SM7 it works with:
http://localhost:13080/SM/PWS

Greets,

Lars
Occasional Advisor
Deepak Narkhede
Posts: 16
Registered: ‎02-28-2008
Message 23 of 26 (1,640 Views)

Re: SC web services

Hi Alfredo,
We are using Sc Webservice since last 2 years. i have seen the code, which you wrote, and i think, there is something missing in your code. We are not using ChangeManagement module, i am sending you and example to create contact in Service center. I hope this will help.


Let me know if you find any issues.

-----------------

'To use this you need to add a web reference of ConfigurationManagement.wsdl

Dim lo_ConFigMgt As New SCenter.ConfigurationManagement
Dim req As New SCenter.CreateContactRequest
Dim res As SCenter.CreateContactResponse
Dim li_ReqCount As Integer



Dim credentialCache As System.Net.CredentialCache = New System.Net.CredentialCache
Dim credentials As System.Net.NetworkCredential = New System.Net.NetworkCredential("sd1", "S3rv1c3D3sk", Nothing)
credentialCache.Add(New Uri(lo_ConFigMgt.Url), "Basic", credentials)

lo_ConFigMgt.Credentials = credentials
lo_ConFigMgt.PreAuthenticate = True

req.model = New SCenter.contactModelType
req.model.keys = New SCenter.contactKeysType
req.model.instance = New SCenter.contactInstanceType

req.model.instance.FirstName = New SCenter.StringType
req.model.instance.FirstName.Value = "Test First Name"


req.model.instance.LastName = New SCenter.StringType
req.model.instance.LastName.Value = "Test Last Name"

req.model.instance.payrollno = New SCenter.StringType
req.model.instance.payrollno.Value = "1010101"

req.model.instance.room = New SCenter.StringType
req.model.instance.room.Value = "Room"

req.model.instance.pagerpin = New SCenter.StringType
req.model.instance.pagerpin.Value = "PagerNumber"

req.model.instance.faxphone = New SCenter.StringType
req.model.instance.faxphone.Value = "FaxNumber"

'The service center format control validates the record been entered.
'You need to enter all the required fields here, else this will cause the API call to fail.

Try
res = lo_ConFigMgt.CreateContact(req)
If res.status = SCenter.StatusType.SUCCESS Then
MessageBox.Show("Contact Created")
Else
MessageBox.Show("Contact Not Created" & res.message.ToString())
End If
Catch ex As Exception
Throw (New Exception(ex.Message))
End Try

lo_ConFigMgt.Dispose()
req = Nothing
Regular Advisor
AAALfredo
Posts: 192
Registered: ‎07-06-2007
Message 24 of 26 (1,640 Views)

Re: SC web services

Hi Deepak, one question, did you test your web services directly from Visual Studio Debuger or did you use a web form that consumed the Web services?
Occasional Advisor
Deepak Narkhede
Posts: 16
Registered: ‎02-28-2008
Message 25 of 26 (1,640 Views)

Re: SC web services

Hi Alfredo,

Have you implemeted the sample code which i provided?

Actually, We have created and internal Website "Service Desk" in our organization to create /view Incidents and Service Requests. Our asp.net application behind the scenes fetch/inserts the data in Service center using SC webservices.

This is the architecture we are using.

DAC (SC Webservices impmentation.)
|
BO (Calling SC webservices - with Parameters)
|
Web Forms (general Action (Add, Delete, update with Parameters))


Let me know if you need any thing from me.
Thanks,
Deepak Narkhede
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.