Tag: web services

WCF:“为MTOM消息创建阅读器时出错”

试图让MTOM在WCF客户端中工作。 我正在尝试使用的特定函数发送一个PDF文档的MTOM编码字节数组。 使用SoapUI使用WSDL测试API工作正常; 但是,当我尝试在客户端中执行相同的操作时,我收到以下错误: Error creating a reader for the MTOM message System.Xml.XmlException: MTOM messages must have type ‘application/xop+xml’. at System.Xml.XmlMtomReader.ReadMessageContentTypeHeader(ContentTypeHeader he ader, String& boundary, String& start, String& startInfo) at System.Xml.XmlMtomReader.Initialize(Stream stream, String contentType, Xml DictionaryReaderQuotas quotas, Int32 maxBufferSize) at System.Xml.XmlMtomReader.SetInput(Stream stream, Encoding[] encodings, Str ing contentType, XmlDictionaryReaderQuotas quotas, Int32 maxBufferSize, OnXmlDic tionaryReaderClose onClose) at […]

无法在ServiceModel客户端配置部分中找到名称为“xxxxx”且合同“yyy”的端点元素

我通过这个命令生成了一个代理 – svcutil.exe / language:cs /out:generatedProxy.cs /config:app.config https://service100.emedny.org:9047/MHService?wsdl 然后将生成的app.config中的元素复制到现有项目的app.config文件中。 当我尝试通过以下方式访问该配置文件中的客户端时 – MHSClient serviceProxy = new MHSClient(“MHSPort”); 它应该引用下面的第二个客户: 但我得到了错误; 无法在ServiceModel客户端配置部分中找到名称为“MHSPort”且收缩“MHS”的端点元素。 这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。 如果我去定义MHSClient,它会将我带到proxy.cs文件和这一行; public partial class MHSClient:System.ServiceModel.ClientBase,MHS 解决了以下问题 – endptAddress = new EndpointAddress(new Uri(“uri”/ xxxx“),EndpointIdentity.CreateDnsIdentity(”xxxxxx“),addressHeaders); MHSClient serviceProxy = new MHSClient(b,endptAddress);

HttpClient响应无法刷新

我正在使用HttpClient与Web服务进行通信以进行发送/接收(以JSON格式响应)。 但我在接收数据时遇到了一些问题。 我每5分钟调用一次Web服务,使用HttpClient在我的Windows手机上刷新内容,但响应反复出现。 为了获得新的响应,我需要退出应用程序并再次呼叫服务。 HttpClient需要一些刷新或清除数据的过程吗? 我是否需要实施其他一些approch来每次获得新的刷新结果? 请建议。 以下是我的实施 public async Task GetMyData(string urlToCall) { try { using (HttpClient httpClient = new HttpClient()) { httpClient.Timeout = TimeSpan.FromMilliseconds(double.Parse(30000)); HttpRequestMessage request = new HttpRequestMessage(System.Net.Http.HttpMethod.Get, urlToCall); var response = await httpClient.SendAsync(request); if (response.StatusCode == HttpStatusCode.OK) { var responseString = await response.Content.ReadAsStringAsync(); return responseString; } else { return string.Empty; } […]

C#:反序列化XML文件错误(认为这是一个命名空间问题 – 但是我的生活不能解决它)

我正在反序列化一个XML文件,该文件来自我们的一个客户的Web服务。 问题是,在使用xsd.exe创建类之后,我将文件反序列化并获得通常的“XML文档中存在错误(2,2)”。 视觉工作室错误。 这个,我假设是第2行,它指向命名空间声明: XML文件的顶部: MX 2009-05-11T09:48:51+01:00 SUPPLIER 12420317323327108 顶级: [System.CodeDom.Compiler.GeneratedCodeAttribute(“xsd”, “2.0.50727.42”)] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute(“code”)] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace=”http://www.mro.com/mx/integration”)] [System.Xml.Serialization.XmlRootAttribute(Namespace=”http://www.mro.com/mx/integration”, IsNullable=false)] public partial class MXWorkorderOutResp { private MXWorkorderOutRespHeader[] headerField; private MXWorkorderOutRespContentMXWORKORDERWORKORDER[][][] contentField; private string languageField; /// [System.Xml.Serialization.XmlElementAttribute(“Header”)] public MXWorkorderOutRespHeader[] Header { get { return this.headerField; } set { this.headerField = value; } } /// [System.Xml.Serialization.XmlArrayItemAttribute(“MXWORKORDER”, typeof(MXWorkorderOutRespContentMXWORKORDERWORKORDER[]), IsNullable=false)] […]

在区域外的MVC应用程序中托管WCF服务

我有一个MVC项目,我在根目录中添加了一个名为WCF的文件夹。 在这个文件夹中,我创建了一个名为CustomFunctions的WCF服务。 当我尝试启动该服务时,收到以下错误: 错误:无法从http://localhost/Viper/WCF/CustomFunctions.svc获取元数据…元数据包含无法解析的引用: 附加说明: 无法找到类型为“Viper.WCF.CustomFunctions”的类型,作为ServiceHost指令中的Service属性值提供,或者在配置元素system.serviceModel / serviceHostingEnvironment / serviceActivations中提供。 昨天我收到了这个错误,花了一些时间在互联网上寻找答案。 这导致我对我的Web.config以及我的Global.asax.cs进行了很多更改。 昨天,它开始工作,我停了下来。 然而,当我今天早上回来时,它再也没有工作。 没有添加任何新内容,也没有更改代码。 我已将以下内容添加到我的Web.config中: 这是我的Global.asax.cs : public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(“{resource}.svc/{*pathInfo}”); routes.MapRoute( “Default”, // Route name “{controller}/{action}/{id}”, // URL with parameters new { controller = “Home”, action = “Index”, id = UrlParameter.Optional }, // Parameter defaults new { controller = “^(?!CustomFunctions).*” […]

C#Web引用调用超时

我正在使用Web引用调用外部服务。 IP是动态的,所以我逐个称呼它们,一切正常。 定期某些IP将无法使用,我正在处理我正在处理的超时。 问题是每次呼叫超时所需的时间大约为30秒。 我尝试将ws上的超时属性更改为5秒,但似乎没有什么区别。 有人可以帮我这个吗?

Web服务一次只允许我获得1000行,但总数超过30000

我正在使用Netsuite提供的一些Web服务https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteFlex/WebServices/STP_searchMore.html#1087957 它只允许我一次获得1000行,然后我需要对下一组1000行执行第二次搜索,依此类推。 有一些示例代码,但它只返回第二组行,我不知道如何获得第三,第四等等。 到目前为止我的代码是: private void getAllCustomers() { // Instantiate a search object for customers. CustomerSearch custSearch = new CustomerSearch(); CustomerSearchBasic custSearchBasic = new CustomerSearchBasic(); // Search the customer status which is a list field (16,13,15) String statusKeysValue = “16,13,15”; SearchMultiSelectField status = null; if (statusKeysValue != null && !statusKeysValue.Trim().Equals(“”)) { status = new SearchMultiSelectField(); […]

无法从ASP.NET调用DLL

嗨,我有一个C dll,它将与cobol应用程序进行交互。 我们想通过互联网将数据发送到cobol。 所以我创建了一个C#DLL,它将调用C DLL。 当我做一个consoleapp时它工作正常,但当我尝试从ASP.NET调用相同的DLL时,它给出错误消息 我不明白这个错误 An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) 还有一些关于此的post,但那些不符合我的上下文我认为我缺少asp.net的permissions 这是我的c#dll中用于调用c dll的声明 [DllImport(@”C:\CCExpert\haz450cp.dll”, EntryPoint = “Methodname”, CallingConvention = CallingConvention.Cdecl)] unsafe public static extern void Methodname(ref p1, ref p2); 编辑: 您好,我根据您的建议更改了设置,但现在我得到一个新的错误 Microsoft Visual Studio C Runtime Library has detected a fatal error […]

使用asp.net和C#从javascript调用外部服务器上的webservice

我正在尝试使用ASP.NET页面测试Web服务调用,该页面创建一个包含用户名和密码字段以及“提交”按钮的表单。 (我正在使用的jQuery和.js文件都包含在head元素的脚本标记中。) “提交”按钮调用在C#代码隐藏文件中创建的函数,该函数调用单独的JavaScript文件。 protected void mSubmit_Click(object sender, EventArgs eventArgs) { String authenticate = String.Format(“Authentication(\”{0}\”,\”{1}\”);”, this.mUsername.Text,this.mPassword.Text); Page.ClientScript.RegisterStartupScript(this.GetType(), “ClientScript”, authenticate, true); } JavaScript函数Authenticate使用jQuery和Ajax对不同的服务器进行Web服务调用,发送JSON参数并期望返回JSON作为响应。 function Authentication(uname, pwd) { //gets search parameters and puts them in json format var params = ‘{“Header”:{“AuthToken”:null,”ProductID”:”NOR”,”SessToken”:null,”Version”:1},”ReturnAuthentication”:true,”Password”:”‘ + pwd + ‘”,”Username”:”‘ + uname + ‘”,”ReturnCredentials”:false }’; var xmlhttp = $.ajax({ async: false, type: “POST”, […]

Webservice C#构造函数不允许参数?

我试图创建一个Web服务,在其构造函数中采取一些参数来保存往返,但我不断收到错误:CS1729“servicename”不包含带有’1’参数的构造函数 虽然当我尝试在本地创建一个即时(在与服务相同的项目中)一切正常但是…给出了什么? 网络服务: public class ayyash : System.Web.Services.WebService { private string _myname; public ayyash (string myname) { _myname = myname; //Uncomment the following line if using designed components //InitializeComponent(); } } 消费: ayyash a = new ayyash(“my name is ayyash”); 输出: Compiler Error Message: CS1729: ‘ayyash’ does not contain a constructor that takes ‘1’ arguments