Web service that accepts a string Soap message as input parameter

How can I accept  a string SOAP message as input variable of a Web Method? I need to treat the SOAP message as an XML Document. This web service returns an error code>Server was unable to process request. --&gt; The path is not of a legal form.</faultstring>
Here is my code:
<WebMethod()> _
     Public Function getOrders(ByVal myString As String) As String
        Dim mCode As String
        Dim eCode As String
         Dim myDoc As New Xml.XmlDocument
        Dim myXML As New Xml.XmlDocument
        myDoc.Load(myString)
        If myDoc Is Nothing Then
            Throw New SoapException("Message was EMPTY XML DOC", SoapException.ClientFaultCode)
        Return "hello World"

    End Function
Thanks in advance
scubamikeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

davidlars99Commented:
looks like that error comes from the function which actualy calls the web service or variable "mtString" which contains URI for SOAP Action, you need to make sure "XML URI"  is a valid path...
0
scubamikeyAuthor Commented:
Please explain. Where should I look for the XML URI valid path?
0
davidlars99Commented:
when SOAP generates an error it sends down a message wrapped up in XML format so that you can debug it, which might look something like this...

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring> Server was unable to process request. --&gt; The path is not of a legal form.</faultstring>
      <faultactor>http://www.domain.com/something/your_web_service.asmx</faultctor>
      <detail />
    </soap:Fault>
  </soap:Body>
</soap:Envelope>


0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

scubamikeyAuthor Commented:
Yes, Here it is:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>Server was unable to process request. --&gt; The path is not of a legal form.</faultstring>
      <detail />
    </soap:Fault>
  </soap:Body>
</soap:Envelope>
What is next ?
0
davidlars99Commented:
OK, I need to look at the entire code, otherwise, if it is a super secret I could give you a little advice and you can try it out by yourself. So, the error says something about illegal path and logicaly speaking how many paths are there in your web service, look at them all and make sure they're all valid, by the way does "myString" variable have any query string values..?
0
scubamikeyAuthor Commented:
<WebMethod()> _
     Public Function getOrders(ByVal myString As String) As String
        Dim mCode As String
        Dim eCode As String
        Dim strResponse As String
        Dim myDoc As New Xml.XmlDocument
        Dim myXML As New Xml.XmlDocument
        myDoc.(myString)
       
        If myDoc Is Nothing Then

            Throw New SoapException("Message was EMPTY XML DOC", SoapException.ClientFaultCode)
        Else
            ImportFile(myDoc)
            Throw New SoapException("Message was processed", SoapException.ClientFaultCode)
        End If
        'errCode(mCode)
        Return "hello World"

    End Function
    Public Function ImportFile(ByVal myDoc As Xml.XmlDocument) As Xml.XmlDocument
        Dim myErr As New Xml.XmlDocument
        Dim Str As String
        Try
            Dim ds As New DataSet

            Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
            'Dim da As New SqlDataAdapter("select * from tblOrders", cn)
            Dim da As New SqlDataAdapter("select * from Orders", cn)


            Dim dr As DataRow
            '*******************
            da.Fill(ds, "Orders")
            dr = ds.Tables(0).NewRow

            ProcessUserID(dr, myDoc)
            ProcessOrderHdr(dr, myDoc)
            ProcessLoanInfo(dr, myDoc)
            ProcessRequest(dr, myDoc)
            'dr("OrderID") = 127
            ds.Tables(0).Rows.Add(dr)
            Dim cd As New SqlCommandBuilder(da)

            da.Update(ds, "Orders")
        Catch ex As Exception

            Throw New SoapException("Message was Bad", SoapException.ClientFaultCode)
        Finally
            'Throw New SoapException("Message was ok", SoapException.ClientFaultCode)
        End Try
        Return myErr

    End Function
    Private Sub ProcessUserID(ByVal dr As DataRow, ByVal myDoc As Xml.XmlDocument)
        Dim Nodes As Xml.XmlNodeList
        Dim Node As Xml.XmlNode
        Dim Node1 As Xml.XmlNode
        Dim Attr As Xml.XmlAttribute
        Dim u As String
        'Try
        Nodes = myDoc.GetElementsByTagName("SOAP-ENV:Header")
        If Nodes.Count <> 1 Then
            Throw New Exception("ERROR PROCESSING REQUEST: REQUEST HEADER NOT PROVIDED")
        End If
        For Each Node In Nodes(0).ChildNodes
            Select Case Node.Name
                Case "Login"
                    For Each Node1 In Node.ChildNodes
                        Select Case Node1.Name
                            Case "Vendor"
                            Case "Username"
                                If (Node1.InnerText) = "xxx" Then
                                    u = (Node1.InnerText)
                                End If
                            Case "Password"
                                If (Node1.InnerText) = "xxxx" Then
                                    'TODO:  sETUP DB PASSWORD AUTHEN
                                    If u <> (Node1.InnerText) Then
                                        Throw New Exception("ERROR PROCESSING REQUEST: REQUEST PASSWORD NOT CORRECT")
                                    End If
                                End If
                        End Select
                    Next
            End Select
        Next
    End Sub

More If needed, But I think you get the general Idea.
In my office I can pass an XML Document ( object) to the web service. I works fine. But my client needs to pass a SOAP message as a string. What a pain.

Thank you,
Mike

Thank you.
0
davidlars99Commented:
I don't see any error there, but there is one thing I'm very concerned about, look at the error message once more and tell me, what does "--&gt;" has to do with this?

Server was unable to process request. --&gt; The path is not of a legal form.


as far as I remmeber if you pass characters like > or < XML automaticaly converts them with "&lt;" and "&gt;", so I want you to check XML which is sent up to the server by your client and make sure XML is clean or post that XML here and I take a quick look at it
0
davidlars99Commented:
consider following XML, when parser sees "> or <" it expects a xml tag if tag is not found you'll get an error

this is invalid XML: <someTag> Math: 6 > 9 = False </someTag>

this is valid XML:   <someTag> Math: 6 &gt; 9 = False </someTag>


0
davidlars99Commented:
so in your case I'm pretty confident that error comes from there..

you said:  In my office I can pass an XML Document ( object) to the web service. I works fine. But my client needs to pass a SOAP message as a string. What a pain.

so, look at the client's message string and post it here...
0
davidlars99Commented:
sorry, when I said
>  if you pass characters like > or < XML automaticaly converts them with "&lt;" and "&gt;",

I was wrong, it's not gonna cnvert them, it will stop and return error.   :)
0
scubamikeyAuthor Commented:
Sorry for the terminology error. client (my customer) not client application. We are trying to receive sales orders from a customer as SOAP message as a string. I can post a XML Document Object just fine.
What am I not understanding about SOAP messages? How does a string SOAP message get readin -or parsed or imported into an XML Document Object??
Stream reader?OBJ.LOAD(mystring) ???
0
davidlars99Commented:
if "myString" is not a file, but valid XML then you don't need to use obj.Load(...), you just go ahead and parse it right there
0
scubamikeyAuthor Commented:
I'll give that a try.
0
davidlars99Commented:
one more thing, when you load xml from a file you must use "myDoc.Load(filename.xml)" when you load straight xml tags you must use "myDoc.LoadXML(xmltags)"  and "xmltags must be "string" type variable


good luck
0
davidlars99Commented:
I got better idea, here's my approach


<WebMethod()> _
     Public Function getOrders(ByVal myString As String) As String
        Dim mCode As String
        Dim eCode As String
        Dim myDoc As New Xml.XmlDocument
        Dim myXML As New Xml.XmlDocument
        If Mid(myString, (Len(myString)-3), 4)=".xml" Then
            myDoc.Load(myString)
        Else
            myDoc.LoadXML(myString)
        End If
        If myDoc Is Nothing Then
            Throw New SoapException("Message was EMPTY XML DOC", SoapException.ClientFaultCode)
        Return "hello World"
    End Function


I hope you don't think you need my explaining here...   :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
scubamikeyAuthor Commented:
This may be what I need. I'll give it a try.
I will let you know how it works
Thanks,
Mike
0
scubamikeyAuthor Commented:
Works great!
Thanks for your Help!
Mike
0
davidlars99Commented:
I am glad I could help Mike!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.