[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Web service that accepts a string Soap message as input parameter

Posted on 2004-11-26
18
Medium Priority
?
1,198 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:scubamikey
  • 11
  • 7
18 Comments
 
LVL 13

Expert Comment

by:davidlars99
ID: 12683792
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
 

Author Comment

by:scubamikey
ID: 12683803
Please explain. Where should I look for the XML URI valid path?
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 12683810
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:scubamikey
ID: 12683821
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
 
LVL 13

Expert Comment

by:davidlars99
ID: 12683840
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
 

Author Comment

by:scubamikey
ID: 12683856
<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
 
LVL 13

Expert Comment

by:davidlars99
ID: 12683894
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
 
LVL 13

Expert Comment

by:davidlars99
ID: 12683949
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
 
LVL 13

Expert Comment

by:davidlars99
ID: 12683965
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
 
LVL 13

Expert Comment

by:davidlars99
ID: 12683971
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
 

Author Comment

by:scubamikey
ID: 12684165
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
 
LVL 13

Expert Comment

by:davidlars99
ID: 12684239
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
 

Author Comment

by:scubamikey
ID: 12684514
I'll give that a try.
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 12684569
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
 
LVL 13

Accepted Solution

by:
davidlars99 earned 1000 total points
ID: 12684613
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
 

Author Comment

by:scubamikey
ID: 12684631
This may be what I need. I'll give it a try.
I will let you know how it works
Thanks,
Mike
0
 

Author Comment

by:scubamikey
ID: 12686239
Works great!
Thanks for your Help!
Mike
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 12686913
I am glad I could help Mike!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question