CA服务台Web服务可视化基础专家

时间:2012-01-24 16:47:34

标签: asp.net

我正在使用CA服务台Web服务请求系统的表单上工作,但是在使用asp.net和visual basic查找服务的任何帮助或编码示例时遇到了困难。我联系了他们的技术支持,但他们的员工中没有人有使用它的经验。你知道我可以在哪里得到帮助吗?

4 个答案:

答案 0 :(得分:3)

刚刚完成对CA服务台的vb.net webservice。希望下面的一些代码可以在您的项目中使用。

Imports System.Xml
Imports Microsoft.Web.Services3
Imports Microsoft.Web.Services3.Messaging
Imports Microsoft.Web.Services3.Addressing

Partial Class _Default
    Inherits System.Web.UI.Page
    Dim ws1 As New USD_WebService.USD_WebService
    Public sid As Integer

    Public userhandle, username, password As String
    Public summary, description, incident, MH, SUN As String
    Public group, category, uammsg, handle As String
    Dim attrVal(5), attr(1), prop(1) As String
    Public requestHandle, requestNumber As String

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click

        ws1.Url = "http://"YOUR SERVER":8080/axis/services/USD_R11_WebService?wsdl"

        'Get the Field values for the ticket (Could be done connecting to LDAP server)
        username = userid1.Value  'Name from form field
        password = pass1.Value    'Windows Password from form field
        summary = Summary1.Value  'Summary from form field
        description = desc1.Value 'Description from form field

'Get the SID from the CA Server
        sid = ws1.login(username, password)

If (sid <= 0) Then
            Response.Write("login failed")
        Else
            Response.Write("login succeeded")
        End If

'Get the User ID from the CA Server
        userhandle = ws1.getHandleForUserid(sid, username)

'Set the Field values to create the ticket. 
        'The AttrVal must be in pairs or the call will fail
        'e.g. header & header details
        attrVal = New String() {"customer", userhandle, "category", category, "group", group, "description", description, "summary", summary, "ZReporting_Method", "400001", "impact", "5", "type", "R"}
        prop = New String() {""}
        attr = New String() {"persistent_id"}

        'Returned data from the CA server
        requestHandle = ""
        requestNumber = ""

        'Send the request with the details from the form
        ws1.createRequest(sid, userhandle, attrVal, prop, "", attr, requestHandle, requestNumber)
        Response.Write("Ticket Number: " + requestNumber + " Created Successfully.")
        'MsgBox("Ticket Number: " + requestNumber + " Created Successfully.")
        MsgBox(requestHandle, 3)
        'Log off the server using the SID
        ws1.logout(sid)

请记住,属性需要成对出现,Label&amp;标签数据,例如“SUMMARY”&amp; “摘要文本”。您需要将CA WebService导入到项目中。我正在使用MS Visual Web Developer 2008 Express来创建我的项目。

答案 1 :(得分:3)

我不使用VB.net实际,但这是C#代码,可以帮助您了解如何访问CA Web服务并直接执行选择quires。你可以翻译成VB.net,它的工作方式相同 You can find how to use web service as pdf hereYou can find CA Reference to web-service here它包含您可能需要的所有对象的说明

webServiceName.USD_WebService wsUSD = new webServiceName.USD_WebService();
string username = "user1" , password = "password";
int sid = 0;
string userhandle = null;
XmlDocument xDoc = new XmlDocument();
sid = wsUSD.login(username, password);
userhandle = wsUSD.getHandleForUserid(sid, username);
string userEmailID = "myMail@company.com";


string[] attrs = new string[7];
attrs[0] = "type.sym";
attrs[1] = "ref_num";
attrs[2] = "open_date";
attrs[3] = "description";
attrs[4] = "status.sym";
attrs[5] = "last_mod_dt";
attrs[6] = "persistent_id";
//here is the important part
//note: 'CL' means closed
//where the cr is Object ref to SQL database
xDoc.LoadXml(wsUSD.doSelect(sid, "cr", " customer.email_address = '" + userEmailID + "' AND status != 'CL'", -1, attrs));
//here is other queries you can use the same way
xDoc.LoadXml(wsUSD.doSelect(sid, "cr", " customer.userid = '" + userEmailID + "'", -1, attrs));
wsUSD.logout(sid);

答案 2 :(得分:2)

在Visual Studio中向Web服务wsdl添加Web引用(在Solutions Explorer下,右键单击References并单击Add Web Reference)。

如果您要跨越环境,我建议使用.xml配置文件来指定WSDL的端点URL。

根据我对它的使用,它在C#中的外观如下:

using webreference1;

public class WSExample
{
   USD_WebService ws = new USD_WebService();
   //set url when creating web reference to avoid this step
   ws.Url = "http://yoursite.com/webservice?wsdl";


}

现在,ws对象将允许您访问wsdl中指定的所有方法。您可以使用createRequest()方法创建请求。

CA提供了技术参考指南,其中包括Web服务方法。咨询他们的支持网站。如果这是你经常使用的东西,我建议创建包装器以抽象使用空白数组。

如果您需要任何其他支持,请随时与我联系

答案 3 :(得分:0)

几个月前,我编写了一些PowerShell函数来查看CA Service Catalog并告诉我基本的事情,例如待处理我的操作的请求,更新请求表单详细信息等。为此,我保存了wsdl xml文件,煮熟了a .cs然后编译一个.dll文件。 通常,我使用此PowerShell函数来编译dll:

    function get-freshDll {
    param($url,$outDir)
      $wsdl = @(Resolve-Path "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\wsdl.exe")[0].Path
      $cscPath = @(Resolve-Path "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe")[0].Path
      & $wsdl  $url /out:$outDir"\WebService.cs"
      & $cscPath /t:library /out:WebService.dll $outDir"\WebService.cs"
    }

适用于其他CA的东西,而不是服务目录(这是我关心的)。对于Service Catalog,您必须保存wsdl文件并删除DataHandler节点(也许其他人知道如何使用它,我放弃了)。之后,创建dll的基本流程是相同的(只需在保存/编辑的wsdl文件中指向wsdl.exe而不是url)然后使用csc.exe编译dll。将此dll的引用添加到C#/ VB项目中。在Service Desk中工作,上面的PowerShell函数应该就像它一样工作,只需将wsdl url和dir提供给你想要dll结束的目录(你可能还需要更改特定版本的netfx和.net的目录) )。 在项目中安装dll之后,您可以使用对象浏览器查看它包含的方法。我自己仍在使用它(因此我发现了这篇文章,如果您认为Service Desk很难找到示例,请尝试使用Service Catalog!)。对于服务台,我没有很好的参考,抱歉,这是.cs代码(几乎是字面上的),它使getRequests和getPendingActions方法从Service Catalog API填充GridView。 aspx:

    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
     <asp:GridView ID="GridView1" runat="server">
     </asp:GridView>
     <asp:GridView ID="GridView2" runat="server">
     </asp:GridView>
    </asp:Content>

请注意,这是来自网络应用,因此上面缺少一行:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" .... blahblah @%>

.cs代码:

     using System;
     using System.Collections.Generic;
     using System.Linq;
     using System.Web;
     using System.Web.UI;
     using System.Web.UI.WebControls;
     using System.Net.Http;
     using System.Net.Http.Formatting;

     namespace MyNamespace
     {
         public partial class MyRequestStuff : System.Web.UI.Page
         {

             protected void Page_Load(object sender, EventArgs e)
             {

                 RequestServiceImplService reqService = new RequestServiceImplService();
                 reqService.CookieContainer = new System.Net.CookieContainer();
                 string user = "userid", password = "password", unit = "Unit";
                 reqService.Url = "http://servicecatalog/usm/services/RequestService?wsdl";
                 string session = reqService.logIn(user, password, unit);
                 var myRequests = reqService.getRequests(session);
                 var myPending = reqService.getPendingActions(session, user);
                 reqService.logOut(session);

                 GridView1.DataSource = myPending;
                 GridView1.DataBind();
                 GridView2.DataSource = myRequests;
                 GridView2.DataBind();

             }
         }
     }

就像baultista和za7ef在他们的代码中提到的那样,你需要创建一个USD_WebService对象(而不是RequestServiceImplService)并使用那里可用的方法(比如getStatuses()),功能将非常相似(它们是在PowerShell中)。我知道它不是很明确(例如SC而不是SD),但我希望你或其他人认为这个例子很有用。