WSDL works locally but not when hosted on a remote server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Joseph Farhat
    New Member
    • Sep 2010
    • 3

    #1

    WSDL works locally but not when hosted on a remote server

    Hello,

    I created a WSDL with Visual Studio 2005 and tested it using localhost. It worked exactly as anticipated and returned the expected results. I basically called the WSDL from a classic ASP page using Server.CreateOb ject("MSXML2.Se rverXMLHTTP.3.0 ") and all went well. The url was http://localhost/service.asmx/methodname.

    I deployed the WSDL to the remote server and tried to access it the same way; I changed localhost with the domain name as http://domainname/service.asmx/methodname. But now I get 'Post to http://domainname/service.asmx/methodname failed with 500.

    I am not sure what to look for. You help is greatly appreciated.

    Thanks
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    There is a "general" error in your service.asmx web service. Check the server logs for details on what is going on.

    -Frinny

    Comment

    • Joseph Farhat
      New Member
      • Sep 2010
      • 3

      #3
      Hello Finny,

      I looked into the logs file and there is nothing there regarding the post I sent through.

      So I decided to use the test with the domain name on the same hosting box (I rdp'd to the remote box, opened a browser and entered the link). I found out that it is throwing a 404 error. so now I am more confused than the first time.

      The files are placed in the wwwroot exactly as it was in the local settings, now when I use localhost instead of the domain name on the remote box it works!

      Does anyone have a clue to what is causing it to behave like this?

      Thanks

      Comment

      • ZiadElmalki
        New Member
        • Sep 2010
        • 43

        #4
        500 is an unhandled exception. In the EventLog->Application ASP.NET logs all unhandled exceptions. Look there and you should see what is causing this error.

        As far as why localhost is working and the domain name is not, I would imagine the bindings are not properly configured for the site in IIS. It should default to listen to all addresses and all hostnames. I am not sure though what version of IIS you are using, if the box is hosting other websites, do multiple hostnames resolve to this one boxes ip, etc.

        Managing IIS7


        Configuring Host Bindings.

        Comment

        • Joseph Farhat
          New Member
          • Sep 2010
          • 3

          #5
          Thank you Ziad for the tip.

          I checked the Application Event log and I found that .Net didn't like http:/domainname/service.asmx/methodname. The summary of the exception is "Exception message: Request format is unrecognized for URL unexpectedly ending in '/getMember'.".

          Now I changed it to http:/domainname/service.asmx?op =methodname; so the error no longer shows in the event log but the response from response.write( o.responseText) return the following:

          "processing posted datasoap:Receiv erSystem.Web.Se rvices.Protocol s.SoapException : Server was unable to process request. ---> System.Xml.XmlE xception: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlT extReaderImpl.T hrow(Exception e) at System.Xml.XmlT extReaderImpl.T hrow(String res, String arg) at System.Xml.XmlT extReaderImpl.P arseRootLevelWh itespace() at System.Xml.XmlT extReaderImpl.P arseDocumentCon tent() at System.Xml.XmlT extReaderImpl.R ead() at System.Xml.XmlT extReader.Read( ) at System.Web.Serv ices.Protocols. SoapServerProto col.SoapEnvelop eReader.Read() at System.Xml.XmlR eader.MoveToCon tent() at System.Web.Serv ices.Protocols. SoapServerProto col.SoapEnvelop eReader.MoveToC ontent() at System.Web.Serv ices.Protocols. SoapServerProto colHelper.GetRe questElement() at System.Web.Serv ices.Protocols. Soap12ServerPro tocolHelper.Rou teRequest() at System.Web.Serv ices.Protocols. SoapServerProto col.RouteReques t(SoapServerMes sage message) at System.Web.Serv ices.Protocols. SoapServerProto col.Initialize( ) at System.Web.Serv ices.Protocols. ServerProtocol. SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) at System.Web.Serv ices.Protocols. ServerProtocolF actory.Create(T ype type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing ) --- End of inner exception stack trace "

          Still can't make sense out of that. I know when run local with '/methodname' it works fine.


          This is a snippet if how I am making the call:
          Code:
             If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
          
               Dim postUrl
               Dim xhr
               Dim DataToSend
          
               DataToSend= "parm1="&Request.Form("parm1")
          
               postUrl = "http://www.domainname.net/servicename.asmx?op=methodname" 
          
               Set xhr = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
               xhr.open "POST", postUrl, false
               xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
               xhr.send DataToSend
               If (xhr.Status = 200) then
                 postFormData = xhr.ResponseText
              Else
                  Err.Raise 1001, "postFormData", "Post to " & postUrl & " failed with " & xhr.Status
              End If
          End If

          Thanks so much for your help
          Last edited by Frinavale; Sep 24 '10, 01:05 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

          Comment

          • ZiadElmalki
            New Member
            • Sep 2010
            • 43

            #6
            This is an asmx webservice. You should be posting an xml soap message.

            Why are you not using the automatically generated proxy?

            Use wsdl.exe http://localhost/myservice.asmx?wsdl

            This will create a code file that you can use to talk to the webservice. Wsdl exe comes with visual studio and the .net sdks.

            Comment

            Working...