Hi David,

First the quick and unfulfilling answer :):

Yes, the namespace prefixes look correct to me based on how you declared the models and your application.

Now for an explanation;

What has happened here is that you've found one of the subtleties of xml namespaces, namespace prefixes and soaplib.

(You can think xml namespaces as something similar to python namespaces. They provide uniquely qualified and named elements within a document.)

If you look at the root element in your soapui response you should see something like:

<senv:Envelope ...  xmlns:tns="eas" ... xmlns:s1="letterstatus" ...>

Here, xmlns:tns="eas" is declaring a namespace prefix "tns" for the namespace you created called "eas". Also, xmlns:s1="letterstatus" is declaring a namespace for "letterstatus" and binding it to the prefix "s1".

"letterstatus" is being created because in your model LetterStatus explicitly declared itself belonging to the namspace "letterstatus" with this line:

class LetterStatus(ClassModel):
    __namespace__ = "letterstatus"
    ...
    ...

If you wish to have LetterStatus belong to the namespace "eas" you need to be explicit about it and modify your namespace declaration. I realize this may seem onerous but, it is like this so that you don't have to couple your models tightly to a single application. Another option is to create an application specific base model and have your app specific models inherit from it. This would look something like this:

APP_NAMESPACE = "app_specific_namespace"

class AppSpecificBaseModel(ClassModel):
    __namespace__ = APP_NAMESPACE

class MyAppModel(AppSpecificBaseModel):
    foo = String
    bar = String
    ...
    ...

I hope this helps.

Cheers


On 03/22/2011 01:25 AM, Dave Dodd wrote:
Gentlefolk,

I have been tasked with replacing an existing set of SOAP services and I have
been experimenting with the using soaplib-2.0.0 beta 2 to do so via a wgsi
handler talking to a Mongrel2 webserver. My handler is using the m2wsgi
python library programatically and is retrieving data from MongoDB instance
via pymongo.  Not too shabby for someone without any real experience with
python or SOAP :)

I have been using soapUI to do my testing which all works as expected,
except I am getting odd namespace prefixes in the responses generated by
soaplib.

I think I have set the namespace for my services correctly in my use of the
soaplib.core.Application function as follows:

        soapapplication = soaplib.core.Application([ClientService], 'eas')

The guts of a request looks like this:

        <eas:RequestLetterStatus>
                <eas:Account>TESTACC</eas:Account>
                <eas:LetterReference>12345</eas:LetterReference>
        </eas:RequestLetterStatus>

The response I get includes:

        <tns:RequestLetterStatusResponse>
                <tns:RequestLetterStatusResult>
                        <s1:LetterStatus>
                                <s1:Status>Unknown</s1:Status>
                        </s1:LetterStatus>
                </tns:RequestLetterStatusResult>
        </tns:RequestLetterStatusResponse>

Are the tns&  s1 namespaces shwoing in the response correct ?

I expected to see the eas namespace I had specified in the call to
soaplib.core.Application().

I have attahced the script I am using.

-- Dave


_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap

_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap

Reply via email to