in reply to Re^2: Perl web service consumed by c# client returns null.
in thread Perl web service consumed by c# client returns null.

Hi Haj,
when I added print "Content-type : text/xml\n\n" in perl webservice, after this there is no content-type error but I am getting below error

Exception: System.InvalidOperationException: Response is not well-form +ed XML. ---> System.Xml.XmlException: Data at the root level is inval +id. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlReader.MoveToContent() at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadRespons +e(SoapClientMessage message, WebResponse response, Stream responseStr +eam, Boolea n asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(Stri +ng methodName, Object[] parameters) --- End of inner exception stack trace --- at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(Stri +ng methodName, Object[] parameters) at Search.MRWebServices__search(String usr, String pw, String extra +Info, String query) at main.Main()

Thank you

Replies are listed 'Best First'.
Re^4: Perl web service consumed by c# client returns null.
by afoken (Chancellor) on Dec 13, 2019 at 10:17 UTC
    Exception: System.InvalidOperationException: Response is not well-formed XML. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1

    So whatever you send to C# is not valid ("well-formed") XML. The problem is found at the first character in the first line, at the root element. See XML and Well-formed document.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^4: Perl web service consumed by c# client returns null.
by haj (Vicar) on Dec 13, 2019 at 10:36 UTC

    Please read carefully what I wrote in my previous response.

    If you print an extra header, then the rest - which contains another HTTP header - is no longer valid XML.

    Now, what happens if you just don't print your own Content-Type header?

      If I don't print my own Content-type, I get below client side exception

      Exception: System.ArgumentNullException: Array cannot be null. Parameter name: bytes at System.Text.Encoding.GetString(Byte[] bytes) at main.Main()

        This is hard to believe. I wrote that you should not print your own content type, but of course you still should print the HTTP response.

        I feel there is a lot of guesswork going on. I haven't seen your code, so I can't help any more. Perhaps you should familiarize yourself with the GET and HEAD tools of LWP (I wrote that already) and examine the output instead of trying to interpret exceptions from some web client.