标签: asmx

为什么WCF有时会在生成的代理类型的末尾添加"Field"?

基本上,我有一个服务器端类型"Foo",成员X和Y.每当我使用Visual Studio的"添加服务器参考"时,我看到WSDL和生成的代理都向所有成员附加单词"Field"并更改第一个字母的外壳.IE,"X"和"Y"被重命名为"xField"和"yField".知道为什么会这样吗?我无法弄清楚这种模式.

详细信息 - 我有一个传统的ASMX Web服务,它公开了一个"Foo"类型.我创建了一个新的WCF服务,它是旧Web服务的包装器 - 新服务只包装这些方法并可能更新几个字段的值,但它公开了完全相同的方法并返回完全相同的类型.我曾多次尝试重新创建referenes,每次都会重命名我的字段:变量"STUFF"在wsdl和proxy中显示为"sTUFFField".变量"X"显示为"xField"等.

有趣的是我无法弄清楚模式 - 我尝试创建一个新的ASMX Web服务作为测试和包装 - 变量不会被重命名.所以我无法弄清楚为什么/何时WCF重命名变量的模式.

有人知道吗?

c# wcf asmx

17
推荐指数
2
解决办法
9562
查看次数

如何从C#webservice生成WSDL文件

我已经创建了这样的WebService:

[WebService(Namespace = "http://ns")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GroupManagerService : WebService
{
    public GroupManagerService()
    {
    }

    [WebMethod]
    public bool MyMethod(string loginname, string country)
    {
        // code here...
    }
}
Run Code Online (Sandbox Code Playgroud)

是否可以为此代码生成WSDL文件而无需连接到正在运行的服务?我搜索,我发现有关信息svcutil.exe的&Wsdl.exe用,但这些只能从运行WebService的检索WSDL时工作.

(对于java,有一个名为java2wsdl的工具,是否有等效的c#?)



:更新:
此问题的上下文是我要向SharePoint添加新的CustomWebService,它应该使用SharePoint上的_vti_bin文件夹中的WSPBuilder进行部署.另请参阅在SharePoint.SE上的帖子.

我想自动生成(使用msbuild命令)'MyServicewsdl.aspx''MyServicedisco.wsdl',它必须放在_vti_bin文件夹中.



也许我错过了一些东西?svcutil.exe的输出是:

bin\Debug>SvcUtil.exe MyWebService.dll
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation.  All rights reserved.

Generating metadata files... …
Run Code Online (Sandbox Code Playgroud)

c# sharepoint wsdl web-services asmx

17
推荐指数
2
解决办法
6万
查看次数

在IIS 7.0上访问.asmx页面时"无法创建XXXX类型"

当我尝试在Web浏览器上访问.asmx文件时,出现此错误消息.消息如下:

说明:解析为此请求提供服务所需的资源时发生错误.请查看以下特定的解析错误详细信息并相应地修改源文件.

分析器错误消息:无法创建类型'GeocachingServerNS.GeocachingServer'.

来源错误:

第1行:<%@ WebService语言="C#"CodeBehind ="GeocachingServer.asmx.cs"Class ="GeocachingServerNS.GeocachingServer"%>

这是我的代码:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;

namespace GeocachingServerNS
{
    public class PlayerInfo
    {
        public string playerName;
        public Position position;

        public PlayerInfo()
        {
        }

        public PlayerInfo(string playerName, Position position)
        {
            this.playerName = playerName;
            this.position = position;
        }
    }

    public class CacheInfo
    {
        public string cacheName;
        public string creatorName;
        public int id;
        public Position position;
        public string hint;
        public string code;

        public CacheInfo() …
Run Code Online (Sandbox Code Playgroud)

.net web-services asmx

16
推荐指数
3
解决办法
2万
查看次数

在ASMX Web服务中使用Server.Execute()呈现UserControl的问题

任何人都可以解释为什么Server.Execute()要求我呈现的UserControls包含<form>标签(或者,我正在做错的是使Server.Execute()在我的UserControls中需要表单标签)?

我创建了一个ASMX服务,通过JQuery + JSON动态加载UserControls,如下所示:

ControlService.asmx

<%@ WebService Language="C#" CodeBehind="ControlService.asmx.cs" Class="ManagementConcepts.WebServices.ControlService" %>
Run Code Online (Sandbox Code Playgroud)

ControlService.cs

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class ControlService : System.Web.Services.WebService
{
    private string GetControl(String controlName, String ClassId)
    {
        Page page = new Page();
        UserControl ctl = (UserControl)page.LoadControl(controlName);

        page.Controls.Add(ctl);
        StringWriter writer = new StringWriter();
        HttpContext.Current.Server.Execute(page, writer, false);
        return writer.ToString();
    }
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string GetSimpleControl(string ClassId)
    {
        return GetControl("SimpleControl.ascx", ClassId);
    }
}
Run Code Online (Sandbox Code Playgroud)

我通过以下JQuery将控件加载到一个页面中,用来自服务返回的HTML替换id为ContentPlaceholder:

JQueryControlLoadExample.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JQueryControlLoadExample.aspx.cs" Inherits="ControlService_Prototype._Default" %>

<!DOCTYPE html …
Run Code Online (Sandbox Code Playgroud)

c# asp.net user-controls asmx

15
推荐指数
1
解决办法
1万
查看次数

如何使用重载方法访问Web服务

我正在尝试在Web服务中重载方法但是在Visual Studio 2005中尝试"添加Web引用"时遇到System.InvalidOperationException(这是相关的代码片段):

public class FileService : System.Web.Services.WebService
{
    private static readonly MetaData[] EmptyMetaData = new MetaData[0];
    public FileService()
    {
    // a few innocent lines of constructor code here...
    }
    [WebMethod(MessageName = "UploadFileBasic", 
        Description = "Upload a file with no metadata properties")]
    public string UploadFile(string trimURL
        , byte[] incomingArray
        , string fileName
        , string TrimRecordTypeName)
    {
        return UploadFile(trimURL
                , incomingArray
                , fileName
                , TrimRecordTypeName
                , EmptyMetaData);
    }
    [WebMethod(MessageName = "UploadFile",
        Description = "Upload a file with an array of metadata …
Run Code Online (Sandbox Code Playgroud)

c# web-services asmx

15
推荐指数
2
解决办法
1万
查看次数

为什么静态方法不能用作ASMX Web服务中的Web服务操作?

我只是想知道为什么我不能在Web服务中使用静态Web方法?为什么限制?

有些人可以给我简明扼要的解释.

c# asp.net web-services asmx

15
推荐指数
1
解决办法
1万
查看次数

有没有办法限制对ASMX Web服务的访问,即asmx页面及其WSDL?

我有一个C#.net webservice,我需要限制访问.我已经要求我的消费者使用用户名和密码来呼叫该服务.但是,有没有办法限制对实际的asmx页面和WSDL的访问?我需要通过用户名/密码和IP地址限制对webservice的访问.如果用户没有正确的凭据,我不希望他们知道Web服务中存在哪些web方法.

这可以通过IIS完成吗?我知道我可以通过IIS限制IP地址,但我还可以使用用户名/密码吗?

有没有其他方法可以在IIS之外执行此操作,也许使用C#.net?

security iis web-services asmx

15
推荐指数
1
解决办法
2万
查看次数

我在哪里设置服务参考的CookieContainer?

例如,在.NET 2.0项目上向ASMX服务添加WebService引用时,

var objService = new NameSpace.groupservices();
Run Code Online (Sandbox Code Playgroud)

那里存在,

objService.CookieContainer = new System.Net.CookieContainer();
Run Code Online (Sandbox Code Playgroud)

例如,在.NET 4.0项目上将ServiceReference添加到ASMX服务时,

var objService = new NameSpace.groupservicesSoapClient();
Run Code Online (Sandbox Code Playgroud)

objService没有任何CookieContainer属性

这里提出一个类似的问题,没有积极的解决方案

有人可以指导在哪里找到该物业?

c# web-services web-reference asmx service-reference

15
推荐指数
3
解决办法
6746
查看次数

PrincipalContext没有连接

我正在尝试将PrincipalContext用于我正在开发的Web服务.我已经在不同的应用程序中的Web服务器上使用表单身份验证,它工作正常.

我收到的错误是:

System.DirectoryServices.AccountManagement.PrincipalServerDownException: The server could not be contacted. ---> System.DirectoryServices.Protocols.LdapException: The LDAP server is unavailable.
   at System.DirectoryServices.Protocols.LdapConnection.Connect()
   at System.DirectoryServices.Protocols.LdapConnection.SendRequestHelper(DirectoryRequest request, Int32& messageID)
   at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout)
   at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request)
   at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
   --- End of inner exception stack trace ---
   at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
   at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
   at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
   at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, String userName, String password)
   at webService.Service1.ValidUser(String sUserName) in E:\Development\CSharpApps\Desktop\OrgChart\webService\Service1.asmx.cs:line …
Run Code Online (Sandbox Code Playgroud)

c# asmx activedirectorymembership

14
推荐指数
1
解决办法
1万
查看次数

无效的JSON原语:id

我无法使以下功能正常工作.这似乎是错误的序列化.这是关于不同数据变体的第5次迭代.我最初只是在做数据:{'id':id}就像我在使用WCF一样,但是使用ASMX它只是不起作用.看起来它将数据序列化为id = 1234而不是id:1234,但我对此很新.任何帮助,将不胜感激.哦,我可以直接在浏览器中调用该服务,它会正确返回数据,所以我知道它不是服务.

function getVentID(id) {
    //look up id in database and get VentID
    alert('id: ' + id);
    var jsdata = { "id": + id}
    $.ajax({
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        url: 'services/UserService.asmx/getVentID',
        data: jsdata,
        dataType: 'json',
        success: function (msg) {
            alert(msg.d);
        },
        error: function (a, b, c) {
            alert('Error: ' + a.toString() + ' ' + b.toString() + " " + c.toString());
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

ps我知道有10个相同的问题,但没有一个我能找到或者对我有用的答案.

jquery web-services asmx

14
推荐指数
1
解决办法
3万
查看次数