Web services 在没有wsdl的情况下调用web服务会导致;500-内部服务器错误。”;
我有一个地址:提供的第三方web服务的地址(提供什么?)。我想构建一个类似的web服务。 当我使用Firefox打开该链接时,服务器会响应:Web services 在没有wsdl的情况下调用web服务会导致;500-内部服务器错误。”;,web-services,soap,wsdl,Web Services,Soap,Wsdl,我有一个地址:提供的第三方web服务的地址(提供什么?)。我想构建一个类似的web服务。 当我使用Firefox打开该链接时,服务器会响应: <env:Envelope> <env:Body> <env:Fault> <faultcode>env:Client</faultcode> <faultstring>Internal Error</fau
<env:Envelope>
<env:Body>
<env:Fault>
<faultcode>env:Client</faultcode>
<faultstring>Internal Error</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>
环境:客户
内部错误
我必须仔细研究和参考主题:
如果我运行我的web服务:远程服务器在代码行返回错误:(500)内部服务器错误:使用(HttpWebResponse=(HttpWebResponse)request.GetResponse())
我的web服务的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Net;
using System.Xml;
using System.IO;
using System.Text;
using System.Collections.Specialized;
namespace WSHelloWord
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public void PostXml(string url)
{
string xml = @"<?xml version=""1.0"" encoding=""utf-8""?><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><HelloWorld3 xmlns=""http://tempuri.org/""><parameter1>test</parameter1><parameter2>23</parameter2><parameter3>test</parameter3></HelloWorld3></soap:Body></soap:Envelope>";
byte[] bytes = Encoding.UTF8.GetBytes(xml);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentLength = bytes.Length;
request.ContentType = "text/xml";
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
if (response.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("POST failed with HTTP {0}",
response.StatusCode);
throw new ApplicationException(message);
}
}
}
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.Services;
Net系统;
使用System.Xml;
使用System.IO;
使用系统文本;
使用System.Collections.Specialized;
名称空间WSHelloWord
{
[WebService(命名空间=”http://tempuri.org/")]
[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
公共类WebService 1:System.Web.Services.WebService
{
[网络方法]
公共void PostXml(字符串url)
{
字符串xml=@“test23test”;
byte[]bytes=Encoding.UTF8.GetBytes(xml);
HttpWebRequest请求=(HttpWebRequest)WebRequest.Create(url);
request.Method=“POST”;
request.ContentLength=字节.Length;
request.ContentType=“text/xml”;
使用(Stream requestStream=request.GetRequestStream())
{
requestStream.Write(字节、0、字节、长度);
}
使用(HttpWebResponse=(HttpWebResponse)request.GetResponse())
{
if(response.StatusCode!=HttpStatusCode.OK)
{
string message=string.Format(“使用HTTP{0}发布失败”,
响应(状态代码);
抛出新的ApplicationException(消息);
}
}
}
}
}
我已尝试编辑您的问题,使其更易于理解。但缺少一些信息,请提供。同时请提供您服务器的堆栈跟踪。您好,Marvin Emil Brach,(提供什么?->税务总局提供1个Web服务地址(app.config):我不知道税务总局的WebService代码,因为他们没有为我提供源代码。我想在我的本地计算机上调用没有wsdl或asmx的WebService:127.0.0.1:2476/WebService1.asmx当前,我使用HttpWebRequest类,但我的代码在服务器Respone:500上有一个错误。我找不到导致此问题的原因。