Millies, Sebastian wrote:
-----Original Message-----
From: Simon Nash [mailto:[email protected]]
Sent: Sunday, November 20, 2011 10:15 PM
To: [email protected]
Subject: Re: Dynamic service references ?
[snip]
The code to serialize a service reference to an XML string looks like
this:
public static String serializeServiceReferenceXML(ServiceReference<?>
sr) throws IOException {
ServiceReferenceImpl<?> sri = (ServiceReferenceImpl<?>) sr;
return sri.toXMLString();
}
The code to deserialize a service reference from an XML string looks
like this:
public static ServiceReference<?> deserializeServiceReferenceXML(String
serializedSR) throws Exception {
StringReader reader = new StringReader(serializedSR);
XMLStreamReader xmlReader =
XMLInputFactory.newInstance().createXMLStreamReader(reader);
ServiceReferenceImpl<?> sri = new ServiceReferenceImpl(xmlReader);
return (ServiceReference<?>) sri;
}
Simon
Hello Simon,
thank you for finding this out.
There's a snag, however, in that serializing/deserializing a
ServiceReference somehow prevents authentication from working.
Example:
On my reference I have put requires="sca:authentication" and have added a
definitions.xml for the policy set just as shown in "Tuscany SCA in Action"
(definitions.xml attached).
Simply calling the injected reference in my SCA component works fine.
Calling a copy of the reference derived by calling
serializeServiceReferenceXML()
followed by deserializeServiceReferenceXML() results in an authentication fault:
- No credentials available for BASIC 'SAP NetWeaver Application Server
[D01/100]'@bla:8000
- Unable to sendViaPost to url[foobaz]
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
[stacktrace snipped]
Setting a breakpoint in BasicAuthenticationReferencePolicyInterceptor#invoke()
demonstrates that this interceptor is not called when the copied reference is
used.
-- Sebastian
I strongly suspect that no-one has ever tried mixing XML serialization
with authentication before.
Would you be able to quickly try doing this with regular Java binary
serialization of the service reference to see if the authentication problem
occurs in this case as well?
Thanks,
Simon
IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Kamyar Niroumand, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany -
Registergericht/Commercial register: Saarbrücken HRB 19681
http://www.softwareag.com