mardi 13 mai 2014

services Web - Connectez un .net 1.1. App à un Webservice .net 4.0 - Stack Overflow


I have a .Net 1.1 App (that cannot be upgraded) that needs to connect to a .Net 4.0 Webservice


When trying to receive the returned object in the app I recieve an XML error


There is an error in XML document (1, 508). at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)


I Have seen some posts that say certain settings must be in place to make them compatible but no "How-To's"


App Code


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

Fails in the Reference.VB [Read-only] file here @ the 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 Code


[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);
}

}

IF I call the Service from a browser i get this Return


<?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>

What do i need to do to get the two talking?



I have a .Net 1.1 App (that cannot be upgraded) that needs to connect to a .Net 4.0 Webservice


When trying to receive the returned object in the app I recieve an XML error


There is an error in XML document (1, 508). at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)


I Have seen some posts that say certain settings must be in place to make them compatible but no "How-To's"


App Code


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

Fails in the Reference.VB [Read-only] file here @ the 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 Code


[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);
}

}

IF I call the Service from a browser i get this Return


<?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>

What do i need to do to get the two talking?


0 commentaires:

Enregistrer un commentaire