未经过身份验证的Web引用用户

时间:2014-02-27 22:19:12

标签: c# asp.net asp.net-mvc asmx

使用带有c#visual studio 12 MVC应用程序的API的Asp.net Web应用程序。我已成功添加了Web引用,并且我在来自Web引用“CatalystCRMWEbservice”的svc.ContactList_Retrieve调用的调用中获得了所有正确的信息,并且它的顺序正确,但我不断收到此错误消息

  

soapException未被用户代码处理,类型异常   发生'System.Web.Services.Protocols.SoapException'   System.Web.Services.dll但未在用户代码中处理

其他信息:服务器无法处理请求。 --->错误:此时无需同步。

以下是家庭控制器的代码。

using pearlsquickalystapp.bc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace pearlsquickalystapp.Controllers
{
    public class HomeController : Controller
    {
     [HttpGet]

        public ActionResult List()
        {

            CatalystCRMWebservice svc = new CatalystCRMWebservice();

            bool more = false;
            int startNumber = 0;

            ContactRecord[] users = svc.ContactList_Retrieve(
            "username", "password", siteId, DateTime.Now.AddDays(-10), ref startNumber,
            ref startNumber, ref more);

            return View("List", users);

        }

    }
}

以下是列表视图的代码。

@model pearlsquickalystapp.bc.ContactRecord []

@{
    ViewBag.Title = "List";
}

<h2>List</h2>


@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>ContactRecord</h4>
        <hr />
        @Html.ValidationSummary(true)

    <div class="form-group">
        @Html.LabelFor(model => model.entityId, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.entityId)
            @Html.ValidationMessageFor(model => model.entityId)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.externalId, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.externalId)
            @Html.ValidationMessageFor(model => model.externalId)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.emailAddress, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.emailAddress)
            @Html.ValidationMessageFor(model => model.emailAddress)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.contactTitle, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.contactTitle)
            @Html.ValidationMessageFor(model => model.contactTitle)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.deleted, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.deleted)
            @Html.ValidationMessageFor(model => model.deleted)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.fullName, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.fullName)
            @Html.ValidationMessageFor(model => model.fullName)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.firstName, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.firstName)
            @Html.ValidationMessageFor(model => model.firstName)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.lastName, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.lastName)
            @Html.ValidationMessageFor(model => model.lastName)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.username, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.username)
            @Html.ValidationMessageFor(model => model.username)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.password, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.password)
            @Html.ValidationMessageFor(model => model.password)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.dateOfBirth, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.dateOfBirth)
            @Html.ValidationMessageFor(model => model.dateOfBirth)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.createDate, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.createDate)
            @Html.ValidationMessageFor(model => model.createDate)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.lastUpdateDate, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.lastUpdateDate)
            @Html.ValidationMessageFor(model => model.lastUpdateDate)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.customerType, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.customerType)
            @Html.ValidationMessageFor(model => model.customerType)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.industryType, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.industryType)
            @Html.ValidationMessageFor(model => model.industryType)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.leadSourceType, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.leadSourceType)
            @Html.ValidationMessageFor(model => model.leadSourceType)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.ratingType, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.ratingType)
            @Html.ValidationMessageFor(model => model.ratingType)
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.MasterOptIn, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.MasterOptIn)
            @Html.ValidationMessageFor(model => model.MasterOptIn)
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Create" class="btn btn-default" />
        </div>
    </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}    

这是请求的Soap数据代码

    POST /CatalystWebService/CatalystCRMWebservice.asmx HTTP/1.1
Host: pearlssportsshop.worldsecuresystems.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/CatalystDeveloperService/CatalystCRMWebservice 
/ContactList_Retrieve"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org  
/soap/envelope/">
  <soap:Body>
<ContactList_Retrieve xmlns="http://tempuri.org/CatalystDeveloperService/CatalystCRMWebservice">
  <username>string</username>
  <password>string</password>
  <siteId>int</siteId>
  <lastUpdateDate>dateTime</lastUpdateDate>
  <recordStart>int</recordStart>
  <moreRecords>boolean</moreRecords>
  </ContactList_Retrieve>
  </soap:Body>
  </soap:Envelope>

我不确定这是否足够。

0 个答案:

没有答案