How to prevent double-slashes in URLs from being replaced?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Benjamin Janecke

    How to prevent double-slashes in URLs from being replaced?

    Hi,

    I have to call a java-written soap webservice from a .NET client
    application. Unfortunately, the URL contains of a double slash "//", as u can
    see in this example:



    ..NET automatically replaces the "//" with a "/" and therefore the call
    fails. Setting the "Url" property of the web service proxy class at runtime
    results in the same behavior.

    As far as I was told, it is NOT against the the standard to use multiple
    slahes in an URL. So is there any way to stop .NET from replacing them?

    thanks in advance,
    Benjamin
  • james

    #2
    Re: How to prevent double-slashes in URLs from being replaced?


    "Benjamin Janecke" <BenjaminJaneck e@discussions.m icrosoft.comwro te in
    message news:161888B6-191D-4473-8170-F6C147707F22@mi crosoft.com...
    Hi,
    >
    I have to call a java-written soap webservice from a .NET client
    application. Unfortunately, the URL contains of a double slash "//", as u
    can
    see in this example:
    >

    >
    .NET automatically replaces the "//" with a "/" and therefore the call
    fails. Setting the "Url" property of the web service proxy class at
    runtime
    results in the same behavior.
    >
    As far as I was told, it is NOT against the the standard to use multiple
    slahes in an URL. So is there any way to stop .NET from replacing them?
    >
    thanks in advance,
    Benjamin
    url = url.replace("//","////");

    (maybe... er...)


    Comment

    • Benjamin Janecke

      #3
      Re: How to prevent double-slashes in URLs from being replaced?

      doesnt work. .net replaces any number of slashes with one single slash.


      "james" wrote:

      url = url.replace("//","////");
      >
      (maybe... er...)
      >
      >
      >

      Comment

      • Marina Levit [MVP]

        #4
        Re: How to prevent double-slashes in URLs from being replaced?

        This has never happened to me.

        If this was the case, no one would ever be able to call a web service.

        What exactly is your code?

        "Benjamin Janecke" <BenjaminJaneck e@discussions.m icrosoft.comwro te in
        message news:161888B6-191D-4473-8170-F6C147707F22@mi crosoft.com...
        Hi,
        >
        I have to call a java-written soap webservice from a .NET client
        application. Unfortunately, the URL contains of a double slash "//", as u
        can
        see in this example:
        >

        >
        .NET automatically replaces the "//" with a "/" and therefore the call
        fails. Setting the "Url" property of the web service proxy class at
        runtime
        results in the same behavior.
        >
        As far as I was told, it is NOT against the the standard to use multiple
        slahes in an URL. So is there any way to stop .NET from replacing them?
        >
        thanks in advance,
        Benjamin

        Comment

        • Benjamin Janecke

          #5
          Re: How to prevent double-slashes in URLs from being replaced?

          Hi,

          don't get me wrong. .NET does not replace the // of the "http://"-part of
          the url. again, the example:



          there is a double-slash in the middle of the url, which gets replaced with a
          single slash. the double slash at the beginning of the url, after the
          protocol name is not affected.

          My code is as simple as that:

          Service.BaanReq uest b = new Service.BaanReq uest();
          b.Url = "http://172.16.0.74:180 88//LM_SoapServices/BaanRequest";

          when i then check the b.Url property in the debugger, i get the folowing
          result:



          So its seems the double slash at the middle of the url was replaced
          immediately after setting the property - even before calling any web method.
          This also happens when I set the url using the app.config file (which is the
          normal way to do this).

          ..NET just doesnt seem to allow for multiple slashes to occurr. I can even do
          this:

          b.Url =
          "http://172.16.0.74:180 88/////////////////LM_SoapServices/BaanRequest";

          and get the same result.


          "Marina Levit [MVP]" wrote:
          This has never happened to me.
          >
          If this was the case, no one would ever be able to call a web service.
          >
          What exactly is your code?
          >
          "Benjamin Janecke" <BenjaminJaneck e@discussions.m icrosoft.comwro te in
          message news:161888B6-191D-4473-8170-F6C147707F22@mi crosoft.com...
          Hi,

          I have to call a java-written soap webservice from a .NET client
          application. Unfortunately, the URL contains of a double slash "//", as u
          can
          see in this example:



          .NET automatically replaces the "//" with a "/" and therefore the call
          fails. Setting the "Url" property of the web service proxy class at
          runtime
          results in the same behavior.

          As far as I was told, it is NOT against the the standard to use multiple
          slahes in an URL. So is there any way to stop .NET from replacing them?

          thanks in advance,
          Benjamin
          >
          >
          >

          Comment

          • Marina Levit [MVP]

            #6
            Re: How to prevent double-slashes in URLs from being replaced?

            I see what you are saying. I don't know why it does that, could be a bug.

            "Benjamin Janecke" <BenjaminJaneck e@discussions.m icrosoft.comwro te in
            message news:CAD37ECC-21B6-444F-8653-7E064085BD80@mi crosoft.com...
            Hi,
            >
            don't get me wrong. .NET does not replace the // of the "http://"-part of
            the url. again, the example:
            >

            >
            there is a double-slash in the middle of the url, which gets replaced with
            a
            single slash. the double slash at the beginning of the url, after the
            protocol name is not affected.
            >
            My code is as simple as that:
            >
            Service.BaanReq uest b = new Service.BaanReq uest();
            b.Url = "http://172.16.0.74:180 88//LM_SoapServices/BaanRequest";
            >
            when i then check the b.Url property in the debugger, i get the folowing
            result:
            >

            >
            So its seems the double slash at the middle of the url was replaced
            immediately after setting the property - even before calling any web
            method.
            This also happens when I set the url using the app.config file (which is
            the
            normal way to do this).
            >
            .NET just doesnt seem to allow for multiple slashes to occurr. I can even
            do
            this:
            >
            b.Url =
            "http://172.16.0.74:180 88/////////////////LM_SoapServices/BaanRequest";
            >
            and get the same result.
            >
            >
            "Marina Levit [MVP]" wrote:
            >
            >This has never happened to me.
            >>
            >If this was the case, no one would ever be able to call a web service.
            >>
            >What exactly is your code?
            >>
            >"Benjamin Janecke" <BenjaminJaneck e@discussions.m icrosoft.comwro te in
            >message news:161888B6-191D-4473-8170-F6C147707F22@mi crosoft.com...
            Hi,
            >
            I have to call a java-written soap webservice from a .NET client
            application. Unfortunately, the URL contains of a double slash "//", as
            u
            can
            see in this example:
            >

            >
            .NET automatically replaces the "//" with a "/" and therefore the call
            fails. Setting the "Url" property of the web service proxy class at
            runtime
            results in the same behavior.
            >
            As far as I was told, it is NOT against the the standard to use
            multiple
            slahes in an URL. So is there any way to stop .NET from replacing them?
            >
            thanks in advance,
            Benjamin
            >>
            >>
            >>

            Comment

            • Greg Young

              #7
              Re: How to prevent double-slashes in URLs from being replaced?

              I might disagree with whoever told you that is compliant.

              per RFC 1630

              " PATH

              The rest of the URI follows the colon in a format depending on the
              scheme. The path is interpreted in a manner dependent on the
              protocol being used. However, when it contains slashes, these
              must imply a hierarchical structure."

              Since the slashes are implying a hierarchical structure is /foo//bar is
              equivalent in the hierarchy to /foo/bar?

              foo <nullbar
              foo bar

              I would say that if these are being looke at in a hierarchical fashio they
              are actually equivalent. I cannot find anywhere in the spec directly
              discussing this though. The only specific case discussed where this is not
              the case in gopher where they are fairly explicit in saying that it is not a
              hierarchical relationship even though it should be, they then go through an
              example of a gopher URI using // which leads me to believe that the the
              intent was to have the two cases be identical.
              Cheers,

              Greg Young
              MVP - C# http://codebetter.com/blogs/gregyoung
              "Benjamin Janecke" <BenjaminJaneck e@discussions.m icrosoft.comwro te in
              message news:161888B6-191D-4473-8170-F6C147707F22@mi crosoft.com...
              Hi,
              >
              I have to call a java-written soap webservice from a .NET client
              application. Unfortunately, the URL contains of a double slash "//", as u
              can
              see in this example:
              >

              >
              .NET automatically replaces the "//" with a "/" and therefore the call
              fails. Setting the "Url" property of the web service proxy class at
              runtime
              results in the same behavior.
              >
              As far as I was told, it is NOT against the the standard to use multiple
              slahes in an URL. So is there any way to stop .NET from replacing them?
              >
              thanks in advance,
              Benjamin

              Comment

              Working...