我有一个需要连接到.Net 4.0 Webservice的.Net 1.1应用程序(无法升级)
当尝试在应用程序中接收返回的对象时,我收到了XML错误
XML文档中存在错误(1,508)。 在System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader,String encodingStyle,XmlDeserializationEvents事件) 在System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader,XmlDeserializationEvents事件) 在System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) 在System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage消息,WebResponse响应,流responseStream,布尔asyncCall) 在System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,Object []参数)
我看过一些帖子说某些设置必须到位以使它们兼容但没有“操作方法”
应用代码
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim WS As New myWS.AddressScrubber
Dim Address As myWS.ScrubberAddress = WS.GetNewAddress(myWS.CustomerTypeEnum.HandEntered)
End Sub
在Reference.VB [只读]文件中失败@Dim results()As Object = Me.Invoke(“GetNewAddress”,New Object(){myCustomerType})line
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://mySite/AddressScrubber/GetNewAddress", RequestNamespace:="http://mySite/AddressScrubber", ResponseNamespace:="http://mySite/AddressScrubber", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
Public Function GetNewAddress(ByVal myCustomerType As CustomerTypeEnum) As ScrubberAddress
Dim results() As Object = Me.Invoke("GetNewAddress", New Object() {myCustomerType})
Return CType(results(0),ScrubberAddress)
End Function
网络服务代码
[WebService(Namespace = "http://mySite/AddressScrubber")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class AddressScrubber : System.Web.Services.WebService
{
[WebMethod(true)]
public ScrubberAddress GetNewAddress(CustomerTypeEnum myCustomerType)
{
return new ScrubberAddress(myCustomerType);
}
}
如果我从浏览器调用服务,我会收到此返回
<?xml version="1.0" encoding="UTF-8"?>
-<ScrubberAddress xmlns="http://mySite/AddressScrubber"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> -<myCustomerType> <ID>2</ID>
<Name>CustomerTypeName</Name> <Description>Customer Type Description</Description>
<Created_Date>2012-06-11T00:00:00</Created_Date> <Deleted>false</Deleted> <Deleted_Date
xsi:nil="true"/> <ScrubberLogs/> </USPSCustomerType> </ScrubberAddress>
我需要做些什么才能让两人说话?