Jquery ajax使用soapui之类的行为调用asmx Web服务

时间:2016-06-08 00:10:30

标签: jquery asp.net web-services soap

我有一个SOAP UI调用正在运行,但我想使用Jquery来实现它,这可能吗?

SOAPUI请求

var maxActive: UInt32 = 0 CGGetActiveDisplayList(0, nil, &maxActive) let displays = Array(fillingBufferOfSize: maxActive) { (buffer, count) in CGGetActiveDisplayList(maxActive, buffer, &count) }

http://rpmdev.company.com/WebServices/wsUserMaint.asmx

然后我从服务器那里得到一个看起来像这样的回复

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rpm="http://www.company.com/rpm">
   <soapenv:Header>
      <rpm:UserMaintanaceHeader>
         <!--Optional:-->
         <rpm:Username>dsd</rpm:Username>
         <!--Optional:-->
         <rpm:Password>asdf</rpm:Password>
         <!--Optional:-->
         <rpm:GeoCode>?</rpm:GeoCode>
      </rpm:UserMaintanaceHeader>
   </soapenv:Header>
   <soapenv:Body>
      <rpm:ResetPassword>
         <!--Optional:-->
         <rpm:Hdr>
            <!--Optional:-->
            <rpm:Username>RPMUser</rpm:Username>
            <!--Optional:-->
            <rpm:Password>cpass</rpm:Password>
            <!--Optional:-->
            <rpm:GeoCode>ABC</rpm:GeoCode>
         </rpm:Hdr>
         <!--Optional:-->

          <rpm:UserID>JMILLER</rpm:UserID>
      </rpm:ResetPassword>
   </soapenv:Body>
</soapenv:Envelope>

网络服务

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <ResetPasswordResponse xmlns="http://www.company.com/rpm">
         <ResetPasswordResult>true</ResetPasswordResult>
      </ResetPasswordResponse>
   </soap:Body>
</soap:Envelope>

(大多数情况下代码是c#,代码恰好是vb.net,但它应该清楚它正在做什么,传入一个复杂的对象HEADER和userID)

所以我想做的是在我的asp.net mvc html razor页面中调用jQuery AJAX来调用web方法(Web服务),然后将响应返回给我?

  1. 甚至可能
  2. 我是否需要将XML构造为字符串?
  3. 我应该使用<WebMethod(Description:="Reset a users password"), SoapHeader("Header", Direction:=SoapHeaderDirection.In)> _ Public Function ResetPassword(ByVal Hdr As UserMaintanaceHeader, ByVal UserID As String) As Boolean Dim blResetPassword As Boolean = False Try Header.Username = Hdr.Username Header.Password = Hdr.Password Header.GeoCode = Hdr.GeoCode Login() 'resetting the password 'Check the SiteID, If empty then default it to -1 Dim SiteID As Integer = -1 _RPMUser = RPMUser.GetUser(UserID, SiteID) _RPMUser.PasswordReset(_ServerName, _ProtocolName) _RPMUser = CType(_RPMUser.Save(), RPMUser) blResetPassword = True Catch ex As Exception HandleWebMethodException(ex) Throw ex End Try Return blResetPassword End Function 吗?
  4. 我需要jsonp吗?
  5. 有关如何执行此操作的任何示例?
  6. 以下是我的开始:

    data: "..."

0 个答案:

没有答案