Hi
I tried using SM7.1 wsdl
http://localhost:13080/sc62server/PWS/Approval.wsdl
and
http://localhost:13080/sc62server/PWS/ChangeManagement.wsdl
I am not a seasoned .Net C# programmer, but have been starting out and developed a few apps. using VS 2008.
I referenced the sample code in the install, the example given on this site, reviewed some HPOV forums as well.
I am having trouble with some basic things.
1) I used a complied wsdl.exe proxy.cs and .dll reference against it in the solution. My code can't seem to successful create an instance of the wsdl using a direct web reference. not sure why?
2) using the proxy.cs and dll, I created a sample code. but was not able to successfully Approve a change ticket. Not sure if my model, instance is wrong, or issues with the keys.
Can someone be kind enough to provide samples or review my code??
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Net; using System.Web.Services; using System.Web.Services.Protocols; using System.Web.UI; using cm3; namespace cm3 { classProgram { [STAThread] staticvoid Main(string[] args) { System.Console.WriteLine("....Program started"); ChangeManagement service = SCFunctions.CreateService(); ChangeInstanceType instanceheader = SCFunctions.SetInstanceValues("RFC"); ApproveChangeResponse response = SCFunctions.Execute(instanceheader, service); Console.WriteLine(response.message); } publicclassSCFunctions { publicstaticChangeManagement CreateService() { ChangeManagement service = newChangeManagement(); service.Credentials = InitCredentials(service); return service; } privateconststring SMUSERNAME = "falcon; privateconststring SMPASSWORD = ""; staticCredentialCache InitCredentials(ChangeManagement svc) { CredentialCache credentialCache = newCredentialCache(); NetworkCredential networkCredentials = newNetworkCredential(); NetworkCredential credentials = newNetworkCredential(SMUSERNAME, SMPASSWORD, null); credentialCache.Add(newUri(svc.Url), "Basic", credentials); return credentialCache; } publicstaticChangeInstanceType SetInstanceValues(String CATEGORY) { ChangeInstanceType instanceheader = newChangeInstanceType(); String sValue = null; StringType stringType = null; sValue = CATEGORY; stringType = newStringType(); stringType.Value = "RFC"; instanceheader.header.Category = stringType; return instanceheader; } publicstaticApproveChangeResponse Execute(ChangeInstanceType instanceheader, ChangeManagement service) { //Create model, keys, response, request MKRR ChangeModelType model = newChangeModelType(); ChangeKeysType keys = newChangeKeysType(); ApproveChangeRequest request = newApproveChangeRequest(); ApproveChangeResponse response = newApproveChangeResponse(); //StringType sValue = new StringType(); //sValue.Value = "CM10269"; //keys.ChangeNumber = sValue; try { model.keys = keys; model.instance = instanceheader; request.model = model; response = service.ApproveChange(request); } catch (Exception ex) { //Console.WriteLine(ex.Message); Console.WriteLine("here is the error"); //return response; } return response; } } } }


Reply With Quote
Bookmarks