By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,948 Members | 1,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,948 IT Pros & Developers. It's quick & easy.

SOAP Interoperability - Urgent

P: n/a
Hi,

I have written a Web Service for a customer which expects a SOAP message
with Document/Literal encoding, and uses
RoutingStyle=SoapServiceRoutingStyle.RequestElemen t to route the SOAP body
message to my Web Method. The Web Method expects a string as its parameter
and then feeds that string to an XML deserializer which maps the XML
elements contained within the string to my custom objects, then performs an
insert/update on an SQL Server database depending on whether the elements
exist in the database or not.

The example SOAP request generated by the .asmx page of my Webservice is:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SendDealerData xmlns="urn:SendDealerData">
<dstDealerData>string</dstDealerData>
</SendDealerData>
</soap:Body>
</soap:Envelope>

Where the dstDealerData node contains the string which is passed to my Web
Method.

My issue is that when I send a request from a c# web services client, all
works perfectly, however when my customer sends a request from their client
(which is generated out of an Oracle database, not sure about the platform)
the request fails, returning the following SOAP fault:

<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>System.Web.Services.Protocols.SoapExc eption: Server was
unable to read request. ---&gt; System.InvalidOperationException: There is
an error in XML document (1, 591). ---&gt; System.Xml.XmlException:
'Element' is an invalid node type. Line 1, position 591.
at System.Xml.XmlReader.ReadElementString()
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read2_SendDealerData()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader)
at System.Web.Services.Protocols.SoapServerProtocol.R eadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.R eadParameters()
at System.Web.Services.Protocols.WebServiceHandler.In voke()
at
System.Web.Services.Protocols.WebServiceHandler.Co reProcessRequest()</faultstring>
<detail />
</soap:Fault>

I have used a trace program to analyse the differences in SOAP requests (the
customer and myself have both sent the same data within the
<dstDealerData></dstDealerData> nodes of the SOAP envelope) - the
difference I have found is that when the data is sent via my c# client, all
'<' and '>' characters within the dstDealerData node are substituted for
'&lt;' and '&gt;' respectively, whilst when my customer sends the request
from their environment, the '<' and '>' characters are retained within the
dstDealerData node. If I use the data from my customer's soap request and
send that from my c# client, all works fine as the c# client performs the
necessary character substitution.

I have tried writing a SOAP Extension which intercepts the incoming SOAP
message before it is passed to my Web Method (in the BeforeDeserialize SOAP
message stage) and performs the necessary character substitution on the '<'
and '>' characters within the <dstDealerData></dstDealerData> nodes of the
message, then rewrites the message to the
HttpContext.Current.Items["SoapMessage"] object, however I now receive the
following SOAP fault:

<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>System.Web.Services.Protocols.SoapExc eption: The root
element for the request could not be determined. When RoutingStyle is set to
RequestElement, SoapExtensions configured via an attribute on the method
cannot modify the request stream before it is read. The extension must be
configured via the SoapExtensionTypes element in web.config, or the request
must arrive at the server as clear text. ---&gt; System.Xml.XmlException:
The root element is missing.
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.MoveToContent()
at
System.Web.Services.Protocols.SoapServerProtocolHe lper.GetRequestElement()
at
System.Web.Services.Protocols.Soap11ServerProtocol Helper.RouteRequest()
--- End of inner exception stack trace ---
at
System.Web.Services.Protocols.Soap11ServerProtocol Helper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.I nitialize()
at System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response,
Boolean&amp; abortProcessing)</faultstring>
<detail />
</soap:Fault>

Which is obviously indicating that I can not use a SOAP extension when the
routing style is set to Request Element. What other options do I have for
making my Web Method accept the data in the format they are sending it? Do I
need to change the type of object my Web Method accepts as a parameter from
string to something else?

Cheers,

Matt
Nov 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.