i copied this xml response and created a class and pasted as special "PasteXMLasClasses" feature of VS IDE. Below the code after i did that.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service
{
// NOTE: Generated code may require at least .NET Framework 4.5 or .NET Core/Standard 2.0.
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.xmlsoap.org/soap/envelope/", IsNullable = false)]
public partial class Envelope
{
private EnvelopeBody bodyField;
/// <remarks/>
public EnvelopeBody Body
{
get
{
return this.bodyField;
}
set
{
this.bodyField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public partial class EnvelopeBody
{
private processResponse processResponseField;
private multiRef[] multiRefField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "https://www.hcsprovider.com/")]
public processResponse processResponse
{
get
{
return this.processResponseField;
}
set
{
this.processResponseField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("multiRef", Namespace = "")]
public multiRef[] multiRef
{
get
{
return this.multiRefField;
}
set
{
this.multiRefField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "https://www.hcsprovider.com/")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "https://www.hcsprovider.com/", IsNullable = false)]
public partial class processResponse
{
private processReturn processReturnField;
private string encodingStyleField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "")]
public processReturn processReturn
{
get
{
return this.processReturnField;
}
set
{
this.processReturnField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public string encodingStyle
{
get
{
return this.encodingStyleField;
}
set
{
this.encodingStyleField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class processReturn
{
private string hrefField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string href
{
get
{
return this.hrefField;
}
set
{
this.hrefField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class multiRef
{
private string authorizedBalanceField;
private object descriptionField;
private string ledgerBalanceField;
private multiRefItem[] itemField;
private ulong cardNumberField;
private bool cardNumberFieldSpecified;
private object employerIDField;
private multiRefMembers membersField;
private string organizationNumberField;
private uint purseNumberField;
private bool purseNumberFieldSpecified;
private string purseTypeField;
private string statusField;
private object responseCodeField;
private object responseMessageField;
private multiRefResultArtifacts resultArtifactsField;
private object soapFaultField;
private string idField;
private byte rootField;
private string encodingStyleField;
private string arrayTypeField;
/// <remarks/>
public string authorizedBalance
{
get
{
return this.authorizedBalanceField;
}
set
{
this.authorizedBalanceField = value;
}
}
/// <remarks/>
public object description
{
get
{
return this.descriptionField;
}
set
{
this.descriptionField = value;
}
}
/// <remarks/>
public string ledgerBalance
{
get
{
return this.ledgerBalanceField;
}
set
{
this.ledgerBalanceField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("item")]
public multiRefItem[] item
{
get
{
return this.itemField;
}
set
{
this.itemField = value;
}
}
/// <remarks/>
public ulong cardNumber
{
get
{
return this.cardNumberField;
}
set
{
this.cardNumberField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool cardNumberSpecified
{
get
{
return this.cardNumberFieldSpecified;
}
set
{
this.cardNumberFieldSpecified = value;
}
}
/// <remarks/>
public object employerID
{
get
{
return this.employerIDField;
}
set
{
this.employerIDField = value;
}
}
/// <remarks/>
public multiRefMembers members
{
get
{
return this.membersField;
}
set
{
this.membersField = value;
}
}
/// <remarks/>
public string organizationNumber
{
get
{
return this.organizationNumberField;
}
set
{
this.organizationNumberField = value;
}
}
/// <remarks/>
public uint purseNumber
{
get
{
return this.purseNumberField;
}
set
{
this.purseNumberField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool purseNumberSpecified
{
get
{
return this.purseNumberFieldSpecified;
}
set
{
this.purseNumberFieldSpecified = value;
}
}
/// <remarks/>
public string purseType
{
get
{
return this.purseTypeField;
}
set
{
this.purseTypeField = value;
}
}
/// <remarks/>
public string status
{
get
{
return this.statusField;
}
set
{
this.statusField = value;
}
}
/// <remarks/>
public object responseCode
{
get
{
return this.responseCodeField;
}
set
{
this.responseCodeField = value;
}
}
/// <remarks/>
public object responseMessage
{
get
{
return this.responseMessageField;
}
set
{
this.responseMessageField = value;
}
}
/// <remarks/>
public multiRefResultArtifacts resultArtifacts
{
get
{
return this.resultArtifactsField;
}
set
{
this.resultArtifactsField = value;
}
}
/// <remarks/>
public object soapFault
{
get
{
return this.soapFaultField;
}
set
{
this.soapFaultField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/encoding/")]
public byte root
{
get
{
return this.rootField;
}
set
{
this.rootField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public string encodingStyle
{
get
{
return this.encodingStyleField;
}
set
{
this.encodingStyleField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/encoding/")]
public string arrayType
{
get
{
return this.arrayTypeField;
}
set
{
this.arrayTypeField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class multiRefItem
{
private string hrefField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string href
{
get
{
return this.hrefField;
}
set
{
this.hrefField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class multiRefMembers
{
private string hrefField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string href
{
get
{
return this.hrefField;
}
set
{
this.hrefField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class multiRefResultArtifacts
{
private string[] itemField;
private string arrayTypeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("item")]
public string[] item
{
get
{
return this.itemField;
}
set
{
this.itemField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/encoding/")]
public string arrayType
{
get
{
return this.arrayTypeField;
}
set
{
this.arrayTypeField = value;
}
}
}
}
Finally, i am trying to deserialize as below:
var str = SOAPHelper.SendSOAPRequest(URL, "process", parameters);
var rawXML = XDocument.Parse(str);
Service.Envelope deserializedObject;
using (var reader = rawXML.CreateReader(System.Xml.Linq.ReaderOptions.None))
{
var ser = new XmlSerializer(typeof(Service.Envelope));
deserializedObject = (Service.Envelope)ser.Deserialize(reader);
}
When i run the applicatiion, am getting error as below
{"There is an error in XML document (0, 0)."}
I am not sure where the error is coming from. please help me solve this issue. i spent lot of time to see whats wrong in the xml string. my bad, i couldn't find it. any help will be highly appreciated.
I try to Deserialize your xml file, and get the error in the "name='TCBalanceInquiryResponse', namespace='urn:BeanService', at <multiRef xmlns=''>".
You can try to modify it according to your requirement.
Best regards,
Sam
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
i would need to achieve using without creating proxy. please help me in this.
Ironically, you are writing a proxy. A very poor implementation but a proxy nonetheless. The rest of the world using the WSDL. Can you explain why you have this requirement? Is this an educational project?
A code generated proxy is not needed if you have the source code; data contracts and service interfaces. From there you can write code to communicate with the service endpoint using the standard WCF library. A proxy is nothing more than a local copy of
the interfaces and types from the remote host. Generally the remote host does not share the source code and exposes the contract in the WSDL. This is a standard. If you wrote the service code then simply use the ServiceHost to open a connection and invoke
the service contracts.
Please see the WCF documentation which covers how to do this.
This url is not created by us. its from our client and they developed using JAVA. its not ASMX or WCF. i dont have WSDL file from client. i have to work without proxy. Any suggestions please
This url is not created by us. its from our client and they developed using JAVA. its not ASMX or WCF. i dont have WSDL file from client. i have to work without proxy. Any suggestions please
You misunderstand. ASMX and WCF are ASP.NET SOAP client and server libraries. The XML shown above is a SOAP message regardless of the language used to create the service. WSDL (Web Service Description Language) is a standard in SOAP. Clients cannot interact
with a SOAP service without knowing the service description. The only reason a SOAP service would not expose the WSDL is because the client does not have permission to use the service.
Keep in mind it's impossible or at least it will take a lot of trial and error to gleam the service definition from a SOAP messages. It's like learning to baking a cake without the recipe and using an existing cake as the template.
Contact the client and ask for the WSDL. At the very least they should have the XSDs.
Member
141 Points
922 Posts
Help Needed in Xml Parsing
Nov 18, 2019 09:11 PM|born2win|LINK
Hi,
I am trying to call web service with no proxy and i am able to achieve it. below the wrapper am using to call the service.
SOAP data (actual) what i receive after calling the service :
i copied this xml response and created a class and pasted as special "PasteXMLasClasses" feature of VS IDE. Below the code after i did that.
Finally, i am trying to deserialize as below:
When i run the applicatiion, am getting error as below
I am not sure where the error is coming from. please help me solve this issue. i spent lot of time to see whats wrong in the xml string. my bad, i couldn't find it. any help will be highly appreciated.
Thank you.
All-Star
53721 Points
24048 Posts
Re: Help Needed in Xml Parsing
Nov 18, 2019 09:38 PM|mgebhard|LINK
It's a lot easier to create a service reference using the WSDL.
Member
141 Points
922 Posts
Re: Help Needed in Xml Parsing
Nov 19, 2019 03:13 AM|born2win|LINK
i would need to achieve using without creating proxy. please help me in this.
Contributor
3370 Points
1409 Posts
Re: Help Needed in Xml Parsing
Nov 19, 2019 10:13 AM|samwu|LINK
Hi born2win,
I try to Deserialize your xml file, and get the error in the "name='TCBalanceInquiryResponse', namespace='urn:BeanService', at <multiRef xmlns=''>".
You can try to modify it according to your requirement.
Best regards,
Sam
All-Star
53721 Points
24048 Posts
Re: Help Needed in Xml Parsing
Nov 19, 2019 01:01 PM|mgebhard|LINK
Ironically, you are writing a proxy. A very poor implementation but a proxy nonetheless. The rest of the world using the WSDL. Can you explain why you have this requirement? Is this an educational project?
A code generated proxy is not needed if you have the source code; data contracts and service interfaces. From there you can write code to communicate with the service endpoint using the standard WCF library. A proxy is nothing more than a local copy of the interfaces and types from the remote host. Generally the remote host does not share the source code and exposes the contract in the WSDL. This is a standard. If you wrote the service code then simply use the ServiceHost to open a connection and invoke the service contracts.
Please see the WCF documentation which covers how to do this.
https://docs.microsoft.com/en-us/dotnet/framework/wcf/how-to-specify-a-service-binding-in-code
Member
141 Points
922 Posts
Re: Help Needed in Xml Parsing
Nov 19, 2019 04:46 PM|born2win|LINK
Hi,
This url is not created by us. its from our client and they developed using JAVA. its not ASMX or WCF. i dont have WSDL file from client. i have to work without proxy. Any suggestions please
All-Star
53721 Points
24048 Posts
Re: Help Needed in Xml Parsing
Nov 19, 2019 04:59 PM|mgebhard|LINK
You misunderstand. ASMX and WCF are ASP.NET SOAP client and server libraries. The XML shown above is a SOAP message regardless of the language used to create the service. WSDL (Web Service Description Language) is a standard in SOAP. Clients cannot interact with a SOAP service without knowing the service description. The only reason a SOAP service would not expose the WSDL is because the client does not have permission to use the service.
Keep in mind it's impossible or at least it will take a lot of trial and error to gleam the service definition from a SOAP messages. It's like learning to baking a cake without the recipe and using an existing cake as the template.
Contact the client and ask for the WSDL. At the very least they should have the XSDs.
Member
141 Points
922 Posts
Re: Help Needed in Xml Parsing
Nov 20, 2019 07:12 PM|born2win|LINK
thank you for the reply . appreciated.