Any luck with Python?

57 views
Skip to first unread message

Terry Simons

unread,
Mar 17, 2011, 12:50:09 AM3/17/11
to ifma...@googlegroups.com
Has anyone had success getting Python (specifically suds) to talk to omapd?

I'll admit that I don't understand the intricacies here, but suds look
like a nice library that *should* be easy to use. ;)

Here's the code I'm using:

from suds.client import Client

client = Client('https://127.0.0.1:8081')

The problem I'm seeing is that instantiating the client triggers a GET
/ request to the server, which hangs until the bowels of python socket
code decide it's timed out.

What would *normally* happen with such a request to a SOAP service?
Does anyone know? Would we get back the WSDL?

Since omapd doesn't load any WSDL files, it seems like this may be an
issue where suds is trying to be smart by requesting the WSDL, and
parsing it, before allowing us to use the instantiated Client object.

Does that sounds plausible? I'm sort of grasping at straws here.

I guess I should go find another WSDL service that "just works" and
poke around a bit.

- Terry

Andrew Benton

unread,
Mar 17, 2011, 2:19:54 PM3/17/11
to ifma...@googlegroups.com
as i recall from fooling with this stuff a year and a half ago, the
URL that you point a client at is expected to return a WSDL. so i
would expect your interpretation of the situation is correct. you may
be able to fake it by loading the wsdl from a local file or fetching
it from a different domain than the one omapd is actually listening
on, but you'll have to investigate the suds api to figure that out :)
you may also be able to get away with not loading a wsdl and just
constructing the soap requests yourself.

Sarab Mattes

unread,
Mar 17, 2011, 3:15:38 PM3/17/11
to ifma...@googlegroups.com, Terry Simons
I don't know anything about suds other than just briefly looking at the documentation.  When you instantiate the Client object, you're supposed to pass in the WSDL.  You're right, omapd won't return a WSDL, so you should just point to a local file.  So maybe something like:

client = Client("file:///path/to/ifmap/wsdl")

You may need to modify your WSDL to point to the https://127.0.0.1:8081 as the SOAP service location.

On Wed, Mar 16, 2011 at 9:50 PM, Terry Simons <terry....@gmail.com> wrote:

JB

unread,
Mar 30, 2011, 8:33:37 AM3/30/11
to ifmapdev
Hello All

It works well with suds. As I mailed earlier to sarab its contacting
the server but the dump counts are not increasing.

This how we create a client
url="file:///C:/directory/directory/directory/ifmap_1_1.wsdl"
client=Client(url)

Now I am trying to use it against IROND and the problem there is that
IROND works with ifmap2 but the WSDL available is based on ifmap1!

could someone please tell me where I could find WSDL for ifmap2 ? if
it exists?

Regards
Ramesh JB

On Mar 17, 8:15 pm, Sarab Mattes <mat...@nixnux.org> wrote:
> I don't know anything about suds other than just briefly looking at the
> documentation.  When you instantiate the Client object, you're supposed to
> pass in the WSDL.  You're right, omapd won't return a WSDL, so you should
> just point to a local file.  So maybe something like:
>
> client = Client("file:///path/to/ifmap/wsdl")
>
> You may need to modify your WSDL to point to thehttps://127.0.0.1:8081as
> the SOAP service location.
>

Sarab Mattes

unread,
Mar 31, 2011, 11:40:16 AM3/31/11
to ifma...@googlegroups.com, JB
I added an IF-MAP V2.0 WSDL, along with the base identifier XSD and metadata for network security XSD, to the omapd Google code site.

Have fun!

Sarab Mattes

unread,
Apr 1, 2011, 12:49:06 PM4/1/11
to Ramesh JB, Arne Welzel, ifma...@googlegroups.com
Ramesh,

I sent in your exact publish XML SOAP envelope and omapd accepted it.  I don't know what to say there.  Are you using omapd-0.4.1?

On Fri, Apr 1, 2011 at 8:13 AM, Ramesh JB <vin...@gmail.com> wrote:
Dear Sarab, Arne

Thank you both for the files. I am having error with the metadata. And when I checked the metadata file which I got from both of you, it shows the following error.

when I opened these files in Microsoft visual studio 

In ifmap-2.0.wsdl
<xsd:import namespace="http://www.trustedcomputinggroup.org/2010/IFMAP-METADATA/2" schemaLocation="ifmap-metadata-2.0v8.xsd"></xsd:import>
the part marked in red has some error and when move mouse over it it says "The schema referenced from this location in your document contains errors"

and when I opened the ifmap-metadata-2.0v8.xsd, I could see that all the lines which contain <xsd:attributeGroup  part shows error

Example:
<xsd:attributeGroup ref="ifmap:singleValueMetadataAttributes"/>
when I move the mouse over the red part it says, Namespace "http://www.trustedcomputinggroup.org/2010/IFMAP/2" is not available to be referenced in this schema"

so then I tried to add this line in metadata file
<xsd:import namespace="http://www.trustedcomputinggroup.org/2010/IFMAP/2" schemaLocation="ifmap-base-2.0v17.xsd"></xsd:import> in the metadata file, as shown below

<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsd:import namespace="http://www.trustedcomputinggroup.org/2010/IFMAP/2" schemaLocation="ifmap-base-2.0v17.xsd"></xsd:import>
  <!-- Schema for IF-MAP Metadata for Network Security -->

I am not sure if it is rite way to do , but after i added it the errors disappeared.

Anyway even after I tried these things I get this metadata error...

Message Sent:
message:
<?xml version="1.0" encoding="UTF-8"?>
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:publish session-id="636e7dc90b200bdc69574eb8c9381097">
         <update lifetime="session">
            <access-request name="131.231.128.28:636e7dc90b200bdc69574eb8c9381097"/>
            <identity name="joe" type="username"/>
            <metadata>
               <meta:authenticated-as xmlns:meta="http://www.trustedcomputinggroup.org/2010/IFMAP-METADATA/2" ifmap-cardinality="singleValue"/>
            </metadata>
         </update>
      </ns0:publish>
   </ns1:Body>
</SOAP-ENV:Envelope>


IROND says 
Servers response to client
(reply){
   errorResult = 
      (ErrorResultType){
         _errorCode = "InvalidMetadata"
         errorString = "bad ifmap-cardinality"
      }
 }

server log
5025354 [Thread-67] DEBUG  - IOException: Client closed connection
5025354 [pool-1-thread-2] TRACE  - EventProcessor: got work to do...
5025354 [pool-1-thread-1] TRACE  - EventProcessor: got work to do...
5025354 [pool-1-thread-2] DEBUG  - Got CloseChannelEvent for 127.0.0.1:4054:62
5025354 [pool-1-thread-2] DEBUG  - No session found for channel
5025354 [pool-1-thread-1] DEBUG  - Got CloseChannelEvent for 127.0.0.1:4053:61
5025355 [pool-1-thread-1] DEBUG  - No session found for channel
5134247 [pool-1-thread-3] TRACE  - EventProcessor: got work to do...
5134247 [pool-1-thread-3] DEBUG  - Processing TimerEvent with session-id 11
5134248 [pool-1-thread-3] DEBUG  - Session for test will be ended because of a timeout.
5134248 [pool-1-thread-3] DEBUG  - EndSession: sessionid=11
5134248 [pool-1-thread-3] TRACE  - Removing 0 session metadata objects
5134248 [pool-1-thread-3] TRACE  - Removing session from Publisher<publisherid=t
est1446614531 sessionid=11>
5134249 [pool-1-thread-3] DEBUG  - Update Subscriptions...
5134249 [pool-1-thread-3] TRACE  - Changed metadata:
5134250 [pool-1-thread-3] DEBUG  - Commit Changes...
5134250 [pool-1-thread-3] DEBUG  - Notify SubscriptionObserver about new results
...


OMAPD says

Servers response to the client:
(reply){
   errorResult = 
      (ErrorResultType){
         _errorCode = "InvalidMetadata"
      }
 }

Server log:
ClientParser::~ClientParser:
ClientHandler::read: Got SOAP Envelope in namespace: "http://www.w3.org/2003/05/soap-envelope"
ClientHandler::readSoapEnvelope: Got SOAP Header in namespace: "http://www.w3.org/2003/05/soap-envelope"
ClientHandler::readSoapEnvelope: Got SOAP Body in namespace: "http://www.w3.org/2003/05/soap-envelope"
ClientHandler::readMapRequest: Got IF-MAP client request: "publish" in namespace: "http://www.trustedcomputinggroup.org/2010/IFMAP/2"
ClientHandler::readIdentifier: Got access-request name: "131.231.128.28:636e7dc90b200bdc69574eb8c9381097"
ClientHandler::readLink: Reading past element: "access-request" of type: "EndElement"
ClientHandler::readIdentifier: Got identity name: "joe"
ClientHandler::readMetadata: Got metadata element: "authenticated-as" in ns: ""
ClientHandler::readMetadata: Error: metadata element has no associated namespace: "authenticated-as"
ClientHandler::readMetadata: Error: metadata element does not specify ifmap-cardinality: "authenticated-as"
ClientHandler::readMetadata: Seting xml for: "authenticated-as" metaXML: "<authenticated-as ifmap-timestamp="2011-04-01T13:28:20" ifmap-publisher-id="131.231.128.28"/>"
ClientHandler::readMetadata: All metadata in request:
"<authenticated-as ifmap-timestamp="2011-04-01T13:28:20" ifmap-publisher-id="131.231.128.28"/>"
Server::readClient: Got request type: "Publish" and IF-MAP version: "IFMAPv20"
Server::readClient: Client Error: "InvalidMetadata"
Server::processPublish: Error in publish: "InvalidMetadata"
Server::sendMapResponse: Sent reply to client:
"<?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Body>
    <ifmap:response>
      <errorResult errorCode="InvalidMetadata"/>
    </ifmap:response>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


I am not sure if the metadata file has any error. or the client is not sending the metadata properly I am trying to correct it.

But would like to know if you have any suggestions about the errors in the xsd files and about the message am sending.

Kind regards
JB

Arne Welzel

unread,
Apr 1, 2011, 1:02:01 PM4/1/11
to ifma...@googlegroups.com
Adding my reply to this thread as well. Should've done it before anyway.

Thanks,
Arne

On Fri, 1 Apr 2011, Ramesh JB wrote:

> Dear Sarab, Arne
>
> Thank you both for the files. I am having error with the metadata. And when
> I checked the metadata file which I got from both of you, it shows the
> following error.

> [...]


> I am not sure if it is rite way to do , but after i added it the errors
> disappeared.

I think we did the same thing when creating code with xjc for some java
MAPCs. Don't think it hurts.

> Anyway even after I tried these things I get this metadata error...
>

> *Message Sent:*


> message:
> <?xml version="1.0" encoding="UTF-8"?>
> <SOAP-ENV:Envelope xmlns:ns0="
> http://www.trustedcomputinggroup.org/2010/IFMAP/2" xmlns:ns1="
> http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
> http://www.w3.org/2003/05/soap-envelope">
> <SOAP-ENV:Header/>
> <ns1:Body>
> <ns0:publish session-id="636e7dc90b200bdc69574eb8c9381097">
> <update lifetime="session">
> <access-request name="131.231.128.28:636
> e7dc90b200bdc69574eb8c9381097"/>
> <identity name="joe" type="username"/>
> <metadata>
> <meta:authenticated-as xmlns:meta="
> http://www.trustedcomputinggroup.org/2010/IFMAP-METADATA/2"
> ifmap-cardinality="singleValue"/>
> </metadata>
> </update>
> </ns0:publish>
> </ns1:Body>
> </SOAP-ENV:Envelope>

Are you really sure, your client is sending this? Using soapui I can
publish this request just fine.
irond actually doesn't print the request that is coming in. If you really
want to see what is coming in, you can start irond using:

java -jar -Djavax.net.debug=all irond.jar

This will give you a bunch of output and eventually what your client is
really sending.


But actually, I think it's _much easier_ with omapd. If you set the debug
level to FFFF (not sure if that's a really meaningful value, but you get
everything this way ;) ), you'll get a line saying:

Server::readClient: Socket data:
[Here will be the request your client "actually" did send]

The log you showed of omapd does not include this part, it would be
interesting to see what was received at the server side.

> I am not sure if the metadata file has any error. or the client is not
> sending the metadata properly I am trying to correct it.
>
> But would like to know if you have any suggestions about the errors in the
> xsd files and about the message am sending.

Try to get information about the requests which arrive at the server, not
those printed by your client. Both servers didn't like what they get and
the request you showed works just fine using soapui, so something fishy
is going on. It's probably due to the missing ifmap-cardinality element,
though. The weirdness is that your client shows this attribute.

Thanks,
Arne

On Fri, 1 Apr 2011, Sarab Mattes wrote:

> Ramesh,
>
> I sent in your exact publish XML SOAP envelope and omapd accepted it. I
> don't know what to say there. Are you using omapd-0.4.1?
>
> On Fri, Apr 1, 2011 at 8:13 AM, Ramesh JB <vin...@gmail.com> wrote:
>
>> Dear Sarab, Arne
>>
>> Thank you both for the files. I am having error with the metadata. And when
>> I checked the metadata file which I got from both of you, it shows the
>> following error.
>>
>> when I opened these files in Microsoft visual studio
>>
>> In ifmap-2.0.wsdl

>> <*xsd:import* namespace="


>> http://www.trustedcomputinggroup.org/2010/IFMAP-METADATA/2"
>> schemaLocation="ifmap-metadata-2.0v8.xsd"></xsd:import>
>> the part marked in red has some error and when move mouse over it it says
>> "The schema referenced from this location in your document contains errors"
>>
>> and when I opened the ifmap-metadata-2.0v8.xsd, I could see that all the
>> lines which contain <xsd:attributeGroup part shows error
>>
>> Example:

>> <*xsd:attributeGroup* ref="ifmap:singleValueMetadataAttributes"/>


>> when I move the mouse over the red part it says, Namespace "
>> http://www.trustedcomputinggroup.org/2010/IFMAP/2" is not available to be
>> referenced in this schema"
>>
>> so then I tried to add this line in metadata file
>> <xsd:import namespace="http://www.trustedcomputinggroup.org/2010/IFMAP/2"
>> schemaLocation="ifmap-base-2.0v17.xsd"></xsd:import> in the metadata file,
>> as shown below
>>
>> <?xml version="1.0" ?>
>> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:ifmap="http://www.trustedcomputinggroup.org/2010/IFMAP/2"
>> xmlns="http://www.trustedcomputinggroup.org/2010/IFMAP-METADATA/2"
>> targetNamespace="
>> http://www.trustedcomputinggroup.org/2010/IFMAP-METADATA/2">

>> *<xsd:import namespace="http://www.trustedcomputinggroup.org/2010/IFMAP/2"
>> schemaLocation="ifmap-base-2.0v17.xsd"></xsd:import>*


>> <!-- Schema for IF-MAP Metadata for Network Security -->
>>
>> I am not sure if it is rite way to do , but after i added it the errors
>> disappeared.
>>
>> Anyway even after I tried these things I get this metadata error...
>>

>> *Message Sent:*


>> message:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <SOAP-ENV:Envelope xmlns:ns0="
>> http://www.trustedcomputinggroup.org/2010/IFMAP/2" xmlns:ns1="
>> http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
>> http://www.w3.org/2003/05/soap-envelope">
>> <SOAP-ENV:Header/>
>> <ns1:Body>
>> <ns0:publish session-id="636e7dc90b200bdc69574eb8c9381097">
>> <update lifetime="session">
>> <access-request name="131.231.128.28:636
>> e7dc90b200bdc69574eb8c9381097"/>
>> <identity name="joe" type="username"/>
>> <metadata>
>> <meta:authenticated-as xmlns:meta="
>> http://www.trustedcomputinggroup.org/2010/IFMAP-METADATA/2"
>> ifmap-cardinality="singleValue"/>
>> </metadata>
>> </update>
>> </ns0:publish>
>> </ns1:Body>
>> </SOAP-ENV:Envelope>
>>
>>
>> IROND says

>> *Servers response to client*


>> (reply){
>> errorResult =
>> (ErrorResultType){
>> _errorCode = "InvalidMetadata"
>> errorString = "bad ifmap-cardinality"
>> }
>> }
>>

>> *server log*

>> *
>> *
>> *


>> Servers response to the client:
>> (reply){
>> errorResult =
>> (ErrorResultType){
>> _errorCode = "InvalidMetadata"
>> }
>> }
>>

>> *
>> *Server log:*

>>> metadata for network security XSD, to the omapd Google code site<http://code.google.com/p/omapd/>

Reply all
Reply to author
Forward
0 new messages