我过去构建过ASP.NET Web服务,这些服务要么是公开使用的,要么是使用Windows身份验证.我现在需要构建一个使用SOAP 1.1协议的Web服务,并且需要使用来自调用者的用户名和密码进行保护.
似乎为WCP 设置基础架构对于一个或两个Web服务来说是过度的.还有其他建议吗?我也在考虑使用ASP.NET 4.0 Beta,如果有人在这个场景中探讨过,那么了解你的意见会很有帮助.
提前感谢您的建议.
我正在构建一个Web服务来接受公司的通知。该公司通知我该服务的结构不正确,并向我提供了可运行的Web服务的.asmx。看起来像这样:
请求:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<AuthenticationInfo
xmlns="http://www.usps.com/postalone/services/UserAuthenticationSchema">
<UserId xmlns="">string</UserId>
<UserPassword xmlns="">string</UserPassword>
</AuthenticationInfo>
<fullServiceAddressCorrectionNotification
xmlns="http://www.usps.com/postalone/services/POCustomerMailXMLServices">string</fullServiceAddressCorrectionNotification>
</soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)
响应:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<FullServiceNixieDetailNotificationResponse
xmlns="http://idealliance.org/maildat/Specs/md091/mailxml70C/mailxml">
<FullServiceNixieDetailNotificationResult>string</FullServiceNixieDetailNotificationResult>
</FullServiceNixieDetailNotificationResponse>
</soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)
我的看起来像这样:请求:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<FullServiceNixieDetailNotification
xmlns="http://idealliance.org/maildat/Specs/md091/mailxml70C/mailxml">
<AuthenticationInfo>
<UserID>string</UserID>
<Password>string</Password>
</AuthenticationInfo>
<fullServiceAddressCorrectionNotification>string</fullServiceAddressCorrectionNotification>
</FullServiceNixieDetailNotification>
</soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)
响应:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<notificationResponse
xmlns="http://www.usps.com/postalone/services/POCustomerMailXMLServices">string</notificationResponse>
</soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)
如您所见,我的东西包裹在一个我需要摆脱的额外元素中。Unfortunatley,我不确定如何执行此操作。我的Web服务代码如下:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data.SqlClient
Public Structure AuthenticationInfoType …Run Code Online (Sandbox Code Playgroud) 我在使用CURL 消费 Web服务时看到了这篇文章:使用php消费WebService
我试图遵循它,但没有运气.我上传了一张我正在尝试访问的网络服务的照片.假设URL为:我将如何根据以下示例制定我的请求:
https://site.com/Spark/SparkService.asmx?op=InsertConsumer

我尝试了这个,但它只返回一个空白页:
$url = 'https://xxx.com/Spark/SparkService.asmx?op=InsertConsumer?NameFirst=Joe&NameLast=Schmoe&PostalCode=55555&EmailAddress=joe@schmoe.com&SurveyQuestionId=76&SurveyQuestionResponseId=1139';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$xmlobj = simplexml_load_string($result);
print_r($xmlobj);
Run Code Online (Sandbox Code Playgroud) 我小心翼翼地进入 WCF,试图按照教程将我的 ASMX 项目转换为一个新的 WCF 项目,我偶然发现了一个关于在 WCF 中编写构造函数的谜团。
我的 ASMX 网络服务允许我有一个构造函数(参见:同名,无返回值):
namespace sdkTrimFileServiceASMX
{
public class FileService : System.Web.Services.WebService
{
Database db;
string g_EventSource = "CBMI-TrimBroker";
string g_EventLog = "Application";
public FileService()
{
try
{
if (!EventLog.SourceExists(g_EventSource))
EventLog.CreateEventSource(g_EventSource, g_EventLog);
}
catch (InvalidOperationException e)
{
e.ToString();
}
}
Run Code Online (Sandbox Code Playgroud)
我将其转换为 WCF 服务应用程序的尝试给出了以下编译器投诉:
The namespace 'sdkTRIMFileServiceWCF' already contains a definition for 'FileService'
Run Code Online (Sandbox Code Playgroud)
这是 WCF 代码(开始片段):
namespace sdkTRIMFileServiceWCF
{
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class FileService : IFileService // err msg points to this line
{
Database …Run Code Online (Sandbox Code Playgroud) 是否可以将DateTime参数发布到ASMX Web服务内的Web方法(使用JSON序列化RPC样式调用)?
我正在向浏览器发送一个DateTime,并以/ Date(1350639464100 + 0100)/的形式序列化.然后我可以使用优秀的moment.js库来解析日期,在页面上显示等.
我的问题是使用AJAX帖子将此日期返回给服务器到我的Web服务.我的web方法看起来像这样:
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void Save(DateTime date)
{
// Do stuff
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试以相同的格式发送日期(/ Date(1350639464100 + 0100)/),那么我收到一个错误:
/ Date(1350639464100 + 0100)/不是DateTime的有效值.
是否有更好的替代方法将其作为字符串发送然后解析服务器上的值?理想情况下,我希望能够在往返服务器的往返中发送对象,而无需更改它们可能包含的任何日期属性.
谢谢你的帮助!
我有以下网络方法
<System.Web.Services.WebMethod()> Public Shared Function NewMethod(ByVal str1 As String) As String
LoadBlock(str1)
Return "Success"
End Function
Run Code Online (Sandbox Code Playgroud)
以及以下程序
Public Sub LoadBlock(ByVal AA As Integer)
panAway.Visible = False '<--ASP panel control
lblHome.Visible = False '<--ASP label control
End
Run Code Online (Sandbox Code Playgroud)
这会引发以下错误
Cannot refer to an instance member of a class from within a shared method or
shared member initializer without an explicit instance of the class.
Run Code Online (Sandbox Code Playgroud)
我知道我收到以下错误,因为我尚未将 LoadBlock 设置为共享
但是如果我这样做了我的程序中的所有控件......会引发上面的错误
我能做些什么吗?
我需要在 OSB 中虚拟化一个 Web 服务,但最终的 wsdl 与业务服务相同(它是一个 asxm,所有内容都只在一个文件中),这是可以的,但是导出 wsdl 后有不同的表示法,请参阅下面的例子:
预期和原始
<wsdl:output>
<soap:body use="literal" />
<soap:header message="tns:GetPPDeluxeSubscriberInformationVersionInfoHeader" part="VersionInfoHeader" use="literal" />
</wsdl:output>
Run Code Online (Sandbox Code Playgroud)
我得到的:
<WL5G3N0:output>
<WL5G3N2:header message="WL5G3N1:GetPPDeluxeSubscriberInformationVersionInfoHeader" part="VersionInfoHeader" use="literal"/>
<WL5G3N2:body use="literal"/>
</WL5G3N0:output>
Run Code Online (Sandbox Code Playgroud)
我得到的符号是 WL5G3N0 或 WL5GN1,而不是肥皂、wsdl 或 tns。
那么有人知道我该如何解决这个问题吗?
谢谢
只有在测试服务器上部署ASMX Web服务时,我才会遇到一个奇怪的问题.我有一个Web服务,只有一个简单的方法:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class HarmonyCentralWebClassicService : System.Web.Services.WebService
{
[WebMethod]
public List<DeviceSync> GetDeviceSyncByCategoryAndSyncStatus(DeviceSyncCategoryId categoryId, DeviceSyncStatusId syncStatusId)
{
// Do something and return a list
return new List<DeviceSync>();
}
}
Run Code Online (Sandbox Code Playgroud)
部署到测试服务器后,当我从另一台机器上的.NET客户端调用此方法时,出现以下错误:
System.Web.Services.Protocols抛出的抓住SoapException :: SoapHttpClientProtocol.ReadResponse
服务器无法识别HTTP标头SOAPAction的值:http: //tempri.org/GetDeviceSyncByCategoryAndSyncStatus
我见过很多SO文章,并试图删除临时ASP网络文件夹和更新Web引用-这些没有工作(如上述在这里).
有谁有想法吗?
我将其从服务器返回到 JSON(一个 jquery 数据表),但它返回错误:
System.InvalidOperationException: A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'.
at WebServices.himher.getUsers1(Int32 iDisplayLength, Int32 iDisplayStart, Int32 iSortCol_0, String sSortDir_0, String sSearch)
Run Code Online (Sandbox Code Playgroud)
.cs代码:
public void getUsers1(int iDisplayLength, int iDisplayStart, int iSortCol_0, string sSortDir_0, string sSearch)
{
try
{
basicoperation bop = new basicoperation();
DataTable dt;
dt = bop.getUsers(iDisplayLength, iDisplayStart, iSortCol_0, sSortDir_0, sSearch); // fetching users
dt.TableName = "usersDT1";
//int iTotalRecords=0;
//int iTotalDisplayRecords= 0;
var retObj = new
{
iTotalRecords= 20,
iTotalDisplayRecords= 10,
aaData= dt …Run Code Online (Sandbox Code Playgroud) 我正在设置我的网站,通过短信接收来自人们的信息.它的工作方式是文本编号,然后该服务将HTTP POST发送到我指定的URL.我听说.asmx文件比.aspx文件更好,因为它们不会经历整个页面生命周期.但是,我真的不明白如何运行.asmx文件,甚至可以通过POST调用它,即www.mysite.com/webservice.asmx?我知道我可以使用.aspx文件,但我想在我开展这项工作之前检查是否有更好的方法.
感谢您的见解!