Work in slow progress
Following the README with the WSRP4J dist I succeded in getting the demo running and heres a dump of the web traffic it generates as captured with the tcpmon tool. The traffic is between the wsrp4j proxy portlet and the wsrp4j-producer (forwarding the jsr168 testportlet that comes with wsrp4j). The portlet page that these (identical) portlets end up in looks like.
What do you have to offer
The first thing the proxyportlet does it to query the wsrp4j-producer about what portlets are available (done with axis 1.4 which the wsrp4j proxyportlet uses):
POST /wsrp4j-producer/services/WSRPServiceDescriptionService HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:9101
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "urn:oasis:names:tc:wsrp:v1:getServiceDescription"
Content-Length: 386
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getServiceDescription xmlns="urn:oasis:names:tc:wsrp:v1:types">
<registrationContext xsi:nil="true" />
</getServiceDescription>
</soapenv:Body>
</soapenv:Envelope>
and the answer is
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Tue, 06 Mar 2007 09:25:03 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getServiceDescriptionResponse
xsi:type="ns1:ServiceDescription"
xmlns="urn:oasis:names:tc:wsrp:v1:types"
xmlns:ns1="urn:oasis:names:tc:wsrp:v1:types">
<ns1:requiresRegistration xsi:type="xsd:boolean">true</ns1:requiresRegistration>
<ns1:requiresInitCookie xsi:type="ns1:CookieProtocol">perGroup</ns1:requiresInitCookie>
</getServiceDescriptionResponse>
</soapenv:Body>
</soapenv:Envelope>
which is kind of an no-answer since it just indicates the it requires registration prior to any thing (
requiresRegistration), and that it requires that cookies are initialized per group (
requiresInitCookie) more about that later.
All right I'll register
Since it requires registration there's only one thing to do:
POST /wsrp4j-producer/services/WSRPRegistrationService HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:9101
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "urn:oasis:names:tc:wsrp:v1:register"
Content-Length: 469
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<register xmlns="urn:oasis:names:tc:wsrp:v1:types">
<consumerName>WSRP4J Proxy Portlet</consumerName>
<consumerAgent>WSRP4J Proxy Portlet</consumerAgent>
<methodGetSupported>false</methodGetSupported>
</register>
</soapenv:Body>
</soapenv:Envelope>
and the producer accepts with:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Tue, 06 Mar 2007 09:25:03 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<registerResponse xmlns="urn:oasis:names:tc:wsrp:v1:types">
<registrationHandle>0:0:0:0:0:0:0:1_1173173104036_0</registrationHandle>
</registerResponse>
</soapenv:Body>
</soapenv:Envelope>
so the
registrationHandle is
0:0:0:0:0:0:0:1_1173173104036_0.
Okay now show me what you offer
After having registred it's now possible to actually get the serviceDescription:
POST /wsrp4j-producer/services/WSRPServiceDescriptionService HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:9101
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "urn:oasis:names:tc:wsrp:v1:getServiceDescription"
Content-Length: 464
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getServiceDescription xmlns="urn:oasis:names:tc:wsrp:v1:types">
<registrationContext>
<registrationHandle>0:0:0:0:0:0:0:1_1173173104036_0</registrationHandle>
</registrationContext>
</getServiceDescription>
</soapenv:Body>
</soapenv:Envelope>
and here goes the answer which is quite verbose since it contains a complete description of the portlet/service. One annoyiance is all the unnessesary
xsi:type the Axis 1.* produces which I've never been able to remove not even with
sendXsiTypes.
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Tue, 06 Mar 2007 09:25:03 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getServiceDescriptionResponse
xsi:type="ns1:ServiceDescription"
xmlns="urn:oasis:names:tc:wsrp:v1:types"
xmlns:ns1="urn:oasis:names:tc:wsrp:v1:types">
<ns1:requiresRegistration xsi:type="xsd:boolean">true</ns1:requiresRegistration>
<ns1:offeredPortlets xsi:type="ns1:PortletDescription">
<ns1:portletHandle xsi:type="xsd:string">wsrp4j-testportlet.WSRP4JTestPortletA</ns1:portletHandle>
<ns1:markupTypes xsi:type="ns1:MarkupType">
<ns1:mimeType xsi:type="xsd:string">text/html</ns1:mimeType>
<ns1:modes xsi:type="xsd:string">wsrp:view</ns1:modes>
<ns1:modes xsi:type="xsd:string">wsrp:edit</ns1:modes>
<ns1:modes xsi:type="xsd:string">wsrp:help</ns1:modes>
<ns1:windowStates xsi:type="xsd:string">wsrp:normal</ns1:windowStates>
<ns1:windowStates xsi:type="xsd:string">wsrp:minimized</ns1:windowStates>
<ns1:windowStates xsi:type="xsd:string">wsrp:maximized</ns1:windowStates>
<ns1:locales xsi:type="xsd:string">en</ns1:locales>
</ns1:markupTypes>
<ns1:groupID xsi:type="xsd:string">wsrp4j-testportlet</ns1:groupID>
<ns1:description
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP4J Test Portlet Description</ns1:value>
</ns1:description>
<ns1:shortTitle
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP4J Test</ns1:value>
</ns1:shortTitle>
<ns1:title
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP4J Test Portlet</ns1:value>
</ns1:title>
<ns1:keywords
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP</ns1:value>
</ns1:keywords>
<ns1:keywords
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP4J</ns1:value>
</ns1:keywords>
<ns1:keywords
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">Test</ns1:value>
</ns1:keywords>
<ns1:usesMethodGet xsi:type="xsd:boolean">false</ns1:usesMethodGet>
<ns1:userContextStoredInSession xsi:type="xsd:boolean">false</ns1:userContextStoredInSession>
<ns1:templatesStoredInSession xsi:type="xsd:boolean">false</ns1:templatesStoredInSession>
<ns1:hasUserSpecificState xsi:type="xsd:boolean">true</ns1:hasUserSpecificState>
<ns1:doesUrlTemplateProcessing xsi:type="xsd:boolean">false</ns1:doesUrlTemplateProcessing>
</ns1:offeredPortlets>
<ns1:offeredPortlets xsi:type="ns1:PortletDescription">
<ns1:portletHandle xsi:type="xsd:string">wsrp4j-testportlet.WSRP4JTestPortletB</ns1:portletHandle>
<ns1:markupTypes xsi:type="ns1:MarkupType">
<ns1:mimeType xsi:type="xsd:string">text/html</ns1:mimeType>
<ns1:modes xsi:type="xsd:string">wsrp:view</ns1:modes>
<ns1:modes xsi:type="xsd:string">wsrp:edit</ns1:modes>
<ns1:modes xsi:type="xsd:string">wsrp:help</ns1:modes>
<ns1:windowStates xsi:type="xsd:string">wsrp:normal</ns1:windowStates>
<ns1:windowStates xsi:type="xsd:string">wsrp:minimized</ns1:windowStates>
<ns1:windowStates xsi:type="xsd:string">wsrp:maximized</ns1:windowStates>
<ns1:locales xsi:type="xsd:string">en</ns1:locales>
</ns1:markupTypes>
<ns1:groupID xsi:type="xsd:string">wsrp4j-testportlet</ns1:groupID>
<ns1:description
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP4J Test Portlet Description</ns1:value>
</ns1:description>
<ns1:shortTitle
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP4J Test</ns1:value>
</ns1:shortTitle>
<ns1:title
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP4J Test Portlet</ns1:value>
</ns1:title>
<ns1:keywords
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP</ns1:value>
</ns1:keywords>
<ns1:keywords
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">WSRP4J</ns1:value>
</ns1:keywords>
<ns1:keywords
lang="en"
xsi:type="ns1:LocalizedString">
<ns1:value xsi:type="xsd:string">Test</ns1:value>
</ns1:keywords>
<ns1:usesMethodGet xsi:type="xsd:boolean">false</ns1:usesMethodGet>
<ns1:userContextStoredInSession xsi:type="xsd:boolean">false</ns1:userContextStoredInSession>
<ns1:templatesStoredInSession xsi:type="xsd:boolean">false</ns1:templatesStoredInSession>
<ns1:hasUserSpecificState xsi:type="xsd:boolean">true</ns1:hasUserSpecificState>
<ns1:doesUrlTemplateProcessing xsi:type="xsd:boolean">false</ns1:doesUrlTemplateProcessing>
</ns1:offeredPortlets>
<ns1:requiresInitCookie xsi:type="ns1:CookieProtocol">perGroup</ns1:requiresInitCookie>
</getServiceDescriptionResponse>
</soapenv:Body>
</soapenv:Envelope>
So there two portlets availeble and they are identified by:
- wsrp4j-testportlet.WSRP4JTestPortletA
- wsrp4j-testportlet.WSRP4JTestPortletB
and the are actually the same portlet, that is portlet code but exposed twice to show of som IPC (Inter Portlet Communication) within a portlet group (portletapplication).
Initializing cookie
Next the cookie is initialized
POST /wsrp4j-producer/services/WSRPBaseService HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:9101
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "urn:oasis:names:tc:wsrp:v1:initCookie"
Content-Length: 442
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<initCookie xmlns="urn:oasis:names:tc:wsrp:v1:types">
<registrationContext>
<registrationHandle>0:0:0:0:0:0:0:1_1173173104036_0</registrationHandle>
</registrationContext>
</initCookie>
</soapenv:Body>
</soapenv:Envelope>
The response body is basicly empty since the cookie comes as a normal HTTP header
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=CD75D795F9463373DD7A0919DF0680E0; Path=/
Content-Type: text/xml;charset=utf-8
Date: Tue, 06 Mar 2007 09:25:03 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<initCookieResponse xmlns="urn:oasis:names:tc:wsrp:v1:types" />
</soapenv:Body>
</soapenv:Envelope>
I don't understand why it's done this way since it's all webservice and not (legacy) browsers, so all clients will be WSRP aware, but I guess the spec writers wanted to stick with known protocols where possible, so the session handling between the consumer and producer uses normal HTTP cookies.
Now discovery and initialization is done and the markup can be exchanged.
Give the markup for the portlet
POST /wsrp4j-producer/services/WSRPBaseService HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:9101
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "urn:oasis:names:tc:wsrp:v1:getMarkup"
Content-Length: 1483
Cookie: JSESSIONID=CD75D795F9463373DD7A0919DF0680E0
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getMarkup xmlns="urn:oasis:names:tc:wsrp:v1:types">
<registrationContext>
<registrationHandle>0:0:0:0:0:0:0:1_1173173104036_0</registrationHandle>
</registrationContext>
<portletContext>
<portletHandle>wsrp4j-testportlet.WSRP4JTestPortletA</portletHandle>
</portletContext>
<runtimeContext>
<userAuthentication>wsrp:none</userAuthentication>
<portletInstanceKey>wsrp4j-proxyportlet_row2_col3_p3</portletInstanceKey>
<namespacePrefix>Pluto_wsrp4j_proxyportlet_row2_col3_p3_</namespacePrefix>
</runtimeContext>
<userContext>
<userContextKey>dummyUserContextKey</userContextKey>
</userContext>
<markupParams>
<secureClientCommunication>false</secureClientCommunication>
<locales>en</locales>
<locales>de</locales>
<mimeTypes>text/html</mimeTypes>
<mode>wsrp:view</mode>
<windowState>wsrp:normal</windowState>
<clientData>
<userAgent>WSRP4J Proxy Portlet</userAgent>
</clientData>
<markupCharacterSets>UTF-8</markupCharacterSets>
<validNewModes>wsrp:view</validNewModes>
<validNewModes>wsrp:help</validNewModes>
<validNewModes>wsrp:edit</validNewModes>
<validNewWindowStates>wsrp:normal</validNewWindowStates>
<validNewWindowStates>wsrp:maximized</validNewWindowStates>
<validNewWindowStates>wsrp:minimized</validNewWindowStates>
</markupParams>
</getMarkup>
</soapenv:Body>
</soapenv:Envelope>
And here it comes (my not so pretty print)
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Tue, 06 Mar 2007 09:25:03 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getMarkupResponse xmlns="urn:oasis:names:tc:wsrp:v1:types">
<markupContext>
<mimeType>text/html; charset=UTF-8</mimeType>
<markupString>
<h2>URL Types Test</h2>Time:Tue Mar 06 10:25:04 CET 2007<BR/>Current
Mode:view<BR/>Current Window State:normal<P/><FONT
SIZE="-1"><BR/><B>Render: </B>Click here on <A
HREF="wsrp_rewrite?wsrp-urlType=render&amp;wsrp-navigationalState=rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAAAAAeA**&amp;wsrp-secureURL=false/wsrp_rewrite">Render</A>
URL.<BR/><BR/><B>Action: </B>Click here on <A
HREF="wsrp_rewrite?wsrp-urlType=blockingAction&amp;wsrp-interactionState=rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAAAABdAAGQUNUSU9OdXIAE1tMamF2YS5sYW5nLlN0cmluZzut0lbn6R17RwIAAHhwAAAAAXQAATF4&amp;wsrp-secureURL=false/wsrp_rewrite">Action</A>
URL.<BR/><I>Group Scope :0</I><BR/><I>Portlet Scope
:0</I><BR/><BR/><B>Resource: </B><BR/><IMG
SRC="wsrp_rewrite?wsrp-urlType=resource&amp;wsrp-url=http%3A%2F%2Flocalhost%3A9101%2Fwsrp4j-testportlet%2Fimages%2Fproject-logo.jpg&amp;wsrp-requiresRewrite=false&amp;wsrp-secureURL=false/wsrp_rewrite"
align="TOP"/><BR/><BR/><B>Namespace:
</B>Pluto_wsrp4j_proxyportlet_row2_col3_p3_someFunctionHere()<BR/><HR/><B>Navigation</B><BR/>Page
1<BR/><A
HREF="wsrp_rewrite?wsrp-urlType=render&amp;wsrp-navigationalState=rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAAAABdAAHanNwTmFtZXVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAl0ZXN0Mi5qc3B4&amp;wsrp-secureURL=false/wsrp_rewrite">Next
&gt;&gt;</A></FONT>
</markupString>
<locale>en</locale>
<requiresUrlRewriting>true</requiresUrlRewriting>
</markupContext>
</getMarkupResponse>
</soapenv:Body>
</soapenv:Envelope>
and the same for the other portlet (ending with B).
please send the image
The portlet has an image
resource that's fetched and cached for the second portlet. The request is a simple HTTP GET request (without a body)
GET /wsrp4j-testportlet/images/project-logo.jpg HTTP/1.1
User-Agent: Java/1.5.0_10
Host: localhost:9101
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
and the answer is the jpeg image in binary so I'll not show that:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
ETag: W/"12241-1171550282000"
Last-Modified: Thu, 15 Feb 2007 14:38:02 GMT
Content-Type: image/jpeg
Content-Length: 12241
Date: Tue, 06 Mar 2007 09:25:04 GMT
and that completes the portlet page that the user sees.