[MOBY-l] A Java web service problem

Michael Gruenberger mgruenb at gmx.net
Tue Mar 2 18:05:08 UTC 2004


Hello everyone,

I've registered a web service written in Java (using AXIS) with BioMOBY,
but I'm having problems with the data type my web service returns. Mark
has already helped me through all the other steps, but I'm completely
stuck here, so any help would be really appreciated! If anyone has
already written a web service in Java that works with BioMOBY it would
be great if you could send me some source code or examples.

OK, here the problem:
My Java web service looks like this:

public String getPBfromGO(String goid)
{
	create a String of XML with data for BioMOBY clients
	Base64 encode and return the String
}

This means that I'm returning a string in the SOAP message:
w3c/XMLSchema-instance/type = http://XMLSchema/string

But Marks client expects:
w3c/XMLSchema-instance/type = http://schemas/soap/encoding/base64

So the question is how to write my Java web service to return a Base64
type instead of a String type (using AXIS)? Or maybe CDATA is easier?

Below is Marks last reply to my problem, which might help clarify my
problem.

Cheers,

Michael.  


-----Forwarded Message-----
From: Mark Wilkinson <markw at illuminae.com>
To: Michael Gruenberger <mgruenb at gmx.net>
Subject: Re: [MOBY] Re: [MISC] Re: Registering existing web services  withMOBY
Date: Tue, 02 Mar 2004 09:09:07 -0800


Below is the message structure from my service first, and then from your
service.  Comments on the messages follow:

================== MINE ==========================
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<namesp36:getGoTermAssociationsResponse
xmlns:namesp36="http://biomoby.org/">
***** <s-gensym106 xsi:type="SOAP-ENC:base64"> *****
PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4K
ICAgICAgPG1vYnk6TU9CWSB4bWxuczptb2J5PSdodHRwOi8vd3d3
LmJpb21vYnkub3JnL21vYnknIHhtbG5zPSdodHRwOi8vd3d3LmJp
b21vYnkub3JnL21vYnknPgogICAgICAgIDxtb2J5OlJlc3BvbnNl
IG1vYnk6YXV0aG9yaXR5PSdpbGx1bWluYWUuY29tJz4KICAgICAg
ICA8bW9ieTpxdWVyeVJlc3BvbnNlIHF1ZXJ5SUQ9JzEnLz4KICAg
IDwvbW9ieTpSZXNwb25zZT4KICAgICAgPC9tb2J5Ok1PQlk+Cg==
</s-gensym106>
</namesp36:getGoTermAssociationsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
=====================================================

===========  YOURS ==================================
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<soapenv:Body>
<ns1:getPBfromGOResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://biomoby.org/">
<ns1:getPBfromGOReturn
***** xsi:type="ns2:string" *****
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns2="http://www.w3.org/2001/XMLSchema">
rO0ABXQByjw/eG1sIHZlcnNpb249JzEuMCcgZW5jb2Rpbmc9J1VURi04Jz8+CiAgIDxtb
QlkgeG1sbnM6bW9ieT0naHR0cDovL3d3dy5iaW9tb2J5Lm9yZy9tb2J5Jz4KICAgICAgP
UmVzcG9uc2UgbW9ieTphdXRob3JpdHk9J2h0dHA6Ly93d3cucGF0aGJhc2UubmV0Jz4KI
ICAgPG1vYnk6cXVlcnlSZXNwb25zZT4KCQk8bW9ieTpDb2xsZWN0aW9uIG1vYnk6YXJ0a
bWU9J0tub3duX1BhdGhiYXNlX0ltYWdlc193aXRoX3NwZWNpZmljX0dPX0lEJz4KCQkgI
OlNpbXBsZT4KCQkgICAgPE9iamVjdCBuYW1lc3BhY2U9J1BhdGhiYXNlX1BCJyBpZD0nJ
ICAgPC9PYmplY3Q+CgkJICA8L21vYnk6U2ltcGxlPgoJCTwvbW9ieTpDb2xsZWN0aW9uP
ICAgICA8L21vYnk6cXVlcnlSZXNwb25zZT4KICAgICAgPC9tb2J5OlJlc3BvbnNlPgogI
Ynk6TU9CWT4K
</ns1:getPBfromGOReturn>
</ns1:getPBfromGOResponse>
</soapenv:Body>
</soapenv:Envelope>
=======================================================

I have put ***'s at the points where the message is wonky.  My message
is encoded in the format (abbreviated URI's):

w3c/XMLSchema-instance/type = http://schemas/soap/encoding/base64

Yours is:

w3c/XMLSchema-instance/type = http://XMLSchema/string

This is no doubt the source of the problem.  Otherwise, your message
structure seems to be compatible with mine in all other ways (that I can
see by eye, though XML isn't particularly human-readable ;-) )

I think once you figure out how to pass base64 encoded data *as* base64
encoded soap content, you will have solved the problem!

> - Do I have to change the return type from String to soemthing else? But
> without hand-coding the SOAP message I can only return native Java
> types, e.g. String, int, float, Hashtable etc and only String seems to
> make sense for XML data

This is beyond my scope of knowlege, I'm afraid...


> My service is sending Base64 at the moment, so if you should be able to
> see in your error logs what the problem is. The debugYourService seems
> to be handling it fine...

It isn't, actually.  If it were working properly it would actually be
decoding it in the very last step, and you would see the base64 printed
to your screen as raw XML... so debugYourService is only getting as far
as it can before stopping.


-- 
Michael Gruenberger
Computer Officer, University of Cambridge
Developer, Pathbase, http://www.pathbase.net
PGP-Public Key ID: 278E1DFF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.open-bio.org/pipermail/moby-l/attachments/20040302/e813080a/attachment.sig>


More information about the moby-l mailing list