haxr (XML RPC) rendering of string values

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

haxr (XML RPC) rendering of string values

Johannes Waldmann
with haxr-20050621, I have trouble interfacing to Java.

When I build an XML RPC call with haxr, containing a struct, I get

<?xml version='1.0' ?>
<methodCall
  ><methodName
    >vorlesungen</methodName
  ><params
    ><param
      ><value
        ><struct
          ><member
            ><name
              >schule</name
            ><value
              ><string
                >HTWK Leipzig</string></value></member> ...

but when I build the same call with org.apache.xmlrpc, I get

<?xml version="1.0"?><methodCall><methodName>vorlesungen</methodName>
<params><param><value><struct><member><name>matrikel</name><value>531</value></member>
<member><name>schule</name><value>HTWK</value></member> ...

the difference is that haxr has extra <string> tags
for values of arguments. I don't think this is right?

Best regards,
--
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- http://www.imn.htwk-leipzig.de/~waldmann/ -------

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: haxr (XML RPC) rendering of string values

Bjorn Bringert-2
Johannes Waldmann wrote:

> with haxr-20050621, I have trouble interfacing to Java.
>
> When I build an XML RPC call with haxr, containing a struct, I get
>
> <?xml version='1.0' ?>
> <methodCall
>   ><methodName
>     >vorlesungen</methodName
>   ><params
>     ><param
>       ><value
>         ><struct
>           ><member
>             ><name
>               >schule</name
>             ><value
>               ><string
>                 >HTWK Leipzig</string></value></member> ...
>
> but when I build the same call with org.apache.xmlrpc, I get
>
> <?xml version="1.0"?><methodCall><methodName>vorlesungen</methodName>
> <params><param><value><struct><member><name>matrikel</name><value>531</value></member>
> <member><name>schule</name><value>HTWK</value></member> ...
>
> the difference is that haxr has extra <string> tags
> for values of arguments. I don't think this is right?
>
> Best regards,

Ah, I seem to have missed one important sentence in the XML-RPC spec
[1]: "If no type is indicated, the type is string.".

The way I understand the spec, having the <string>...</string> is
optional. So what HAXR produces is valid and should be accepted by any
implementation. However, I think HaXR won't accept a call without an
explicit type tag. In other words, I would expect HaXR's calls to be
understood by anyone, but that HaXR won't understand all valid calls. Is
that what happens?

/Björn

[1] http://www.xmlrpc.com/spec
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: haxr (XML RPC) rendering of string values

Johannes Waldmann

> explicit type tag. In other words, I would expect HaXR's calls to be
> understood by anyone, but that HaXR won't understand all valid calls. Is
> that what happens?

Yes, this is what it looks like for the one direction I checked
(Client: java, Server: haxr) - Best regards,
--
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- http://www.imn.htwk-leipzig.de/~waldmann/ -------

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: haxr (XML RPC) rendering of string values

Bjorn Bringert-2
In reply to this post by Johannes Waldmann
Johannes Waldmann wrote:

> with haxr-20050621, I have trouble interfacing to Java.
>
> When I build an XML RPC call with haxr, containing a struct, I get
>
> <?xml version='1.0' ?>
> <methodCall
>   ><methodName
>     >vorlesungen</methodName
>   ><params
>     ><param
>       ><value
>         ><struct
>           ><member
>             ><name
>               >schule</name
>             ><value
>               ><string
>                 >HTWK Leipzig</string></value></member> ...
>
> but when I build the same call with org.apache.xmlrpc, I get
>
> <?xml version="1.0"?><methodCall><methodName>vorlesungen</methodName>
> <params><param><value><struct><member><name>matrikel</name><value>531</value></member>
> <member><name>schule</name><value>HTWK</value></member> ...
>
> the difference is that haxr has extra <string> tags
> for values of arguments. I don't think this is right?

There is an fix in darcs now. It's untested; I'll test it as soon as I
get a test environment set up. Let me know how it works out for you.
Thanks to Malcom Wallace for suggesting a low-resistance way to fix this.

/Björn
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: haxr (XML RPC) rendering of string values

Johannes Waldmann

> There is an fix in darcs now. It's untested; I'll test it as soon as I
> get a test environment set up. Let me know how it works out for you.

thanks for the fix. now there seems to be another  problem:
my java client (using  org.apache.xmlrpc.XmlRpcClientLite)
seems to encode spaces in strings when it creates a Request,
but haxr does not seem to decode this.

My Haskell function on the Server gets to see something like
Actor { schule = "HTWK&#32;Leipzig" , matrikel = "531" }
when actually it should be
Actor { schule = "HTWK Leipzig" , matrikel = "531" }
(this latter form is also constructed by the haxr client).

Best regards,
--
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- http://www.imn.htwk-leipzig.de/~waldmann/ -------

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: haxr (XML RPC) rendering of string values

Bjorn Bringert-2
Johannes Waldmann wrote:

>>There is an fix in darcs now. It's untested; I'll test it as soon as I
>>get a test environment set up. Let me know how it works out for you.
>
>
> thanks for the fix. now there seems to be another  problem:
> my java client (using  org.apache.xmlrpc.XmlRpcClientLite)
> seems to encode spaces in strings when it creates a Request,
> but haxr does not seem to decode this.
>
> My Haskell function on the Server gets to see something like
> Actor { schule = "HTWK&#32;Leipzig" , matrikel = "531" }
> when actually it should be
> Actor { schule = "HTWK Leipzig" , matrikel = "531" }
> (this latter form is also constructed by the haxr client).
>
> Best regards,

Ah, that's a clever way to get around the problems in the XML-RPC spec
regarding the treatment of whitespace in string values.

The spec says:

"Any characters are allowed in a string except < and &, which are
encoded as &lt; and &amp;. A string can be used to encode binary data."

Nothing is said about which additional entities should be supported in
the input. I'm looking into this.

/Björn
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: haxr (XML RPC) rendering of string values

Johannes Waldmann

> "Any characters are allowed in a string except < and &, which are
> encoded as &lt; and &amp;. A string can be used to encode binary data."

I made the quick "fix" of adding the last line in Internals:

readString :: Monad m => String -> Err m String
readString = return . replace "&amp;" "&" . replace "&lt;" "<"
             . replace "&gt;" ">"
             . replace "&#32;" " "
--
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- http://www.imn.htwk-leipzig.de/~waldmann/ -------

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: haxr (XML RPC) rendering of string values

Bjorn Bringert-2
Johannes Waldmann wrote:

>>"Any characters are allowed in a string except < and &, which are
>>encoded as &lt; and &amp;. A string can be used to encode binary data."
>
>
> I made the quick "fix" of adding the last line in Internals:
>
> readString :: Monad m => String -> Err m String
> readString = return . replace "&amp;" "&" . replace "&lt;" "<"
>              . replace "&gt;" ">"
>              . replace "&#32;" " "

Since this only adds to my already incredibly inefficient hack for
handling entity references, it's of course not a long term solution.
I'll try to write something better. I had forgotten that I used this
crazy hack.

/Björn
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries