Compare commits

..

103 Commits

Author SHA1 Message Date
rayw%netscape.com
102abfaf95 Updated the list of IDL files.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@109128 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-28 10:13:32 +00:00
rayw%netscape.com
303b94b230 Updates.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@109127 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-28 10:09:30 +00:00
rayw%netscape.com
a214bbc93b More fixes for soap stuff.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108927 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-26 22:31:43 +00:00
rayw%netscape.com
4a35edca7c Miscellaneous fixes to make shared library load.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108864 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-24 23:55:25 +00:00
rayw%netscape.com
84c4f735c8 Fixed more problems with build.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108862 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-24 22:39:29 +00:00
rayw%netscape.com
ede731b482 Fixes to make it added in build on Linux
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108857 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-24 16:36:39 +00:00
rayw%netscape.com
5189d96611 Added JS initializer using new functionality.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108843 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 19:03:32 +00:00
rayw%netscape.com
3c9c87d3cd Updated http transport.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108841 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 17:22:02 +00:00
rayw%netscape.com
abc647b7bf Eliminate unused JS IDL.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108836 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 14:42:04 +00:00
rayw%netscape.com
514deaf34b Eliminate unused IDL.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108835 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 14:40:43 +00:00
rayw%netscape.com
a0bbdbe2d9 Get the element namespace and name before looking it up. Also, as a last
effort to identify the type, if the namespaceURI belongs to the SOAP
encoding, then compute the type from that and try to look it up.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108834 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 14:39:21 +00:00
rayw%netscape.com
0945394e50 Eliminated need for encoding contractID, made all registered services
available as styles in the default encoding, and fixed to create
services.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108824 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 23:14:03 +00:00
rayw%netscape.com
5e6cfecab1 Fixed type lookup on decoders with no explicit type.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108823 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 22:40:47 +00:00
rayw%netscape.com
6e8995843f Added contract ID for default encoder.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108814 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 18:50:56 +00:00
rayw%netscape.com
fb1f129a33 Eliminated JS stuff.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108812 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 18:41:10 +00:00
rayw%netscape.com
c59d8f9d70 Eliminated dead code.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108811 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 18:22:54 +00:00
rayw%netscape.com
d507f13f1e More fixes in encoders.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108810 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 18:19:17 +00:00
rayw%netscape.com
981450bd1e More progress on encoding / decoding.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108808 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 17:10:16 +00:00
rayw%netscape.com
c8325f0bab A few more decoders.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108795 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 05:14:19 +00:00
rayw%netscape.com
cdff0f18b7 Some basic encoders and decoders there.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108787 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 03:11:45 +00:00
rayw%netscape.com
aa259d79a4 Fixed argument handling.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108717 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-21 20:42:02 +00:00
rayw%netscape.com
d5313c3c3c More fixes for changing includes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108714 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-21 19:46:23 +00:00
rayw%netscape.com
760ef56127 The updated version of several implementations to use variants.
The Serializer / Deserializer is still undefined.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108199 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-15 22:55:34 +00:00
rayw%netscape.com
668c500732 Changes to SOAP APIs to use variants. On branch, not part of
default build.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108198 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-15 22:54:38 +00:00
rayw%netscape.com
9b3e0d9b4a Changes found on laptop
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@106042 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-23 11:47:58 +00:00
rayw%netscape.com
d08dfe2340 Temporary fixes to string calls until variant is used.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@106040 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-23 11:15:00 +00:00
rayw%netscape.com
cdb804758f Renamed TypeRegistry to encodingRegistry and changed the arguments to
encode and decode (yet again) to be closer to what they need to be like
in a world of variants and schema.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@102035 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-30 20:37:25 +00:00
rayw%netscape.com
532b55f3a2 Broke out schema namespace URI from schema type
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101982 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-29 22:32:23 +00:00
rayw%netscape.com
2e5f028235 Changed the abstraction for encoders to not rely on message.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101966 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-29 21:03:38 +00:00
rayw%netscape.com
d6b1f0b24b Renaming IDs to types.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101927 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-29 01:21:59 +00:00
rayw%netscape.com
0b71d52a13 changed signatures of encoding / decoding.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101926 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-29 01:09:21 +00:00
rayw%netscape.com
c4e2131b79 Added back changes which were lost, byte -> char.
Renamed marshaller -> encoder unmarshaller -> decoder.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101920 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-28 23:05:32 +00:00
rayw%netscape.com
d3497e2e42 Eliminated recent bit rot related to elimination of a macro.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@100672 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-09 20:29:59 +00:00
rayw%netscape.com
e2087f1048 Renamed types for less confusion, use PRInt16 instead of char.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99211 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-13 20:28:41 +00:00
rayw%netscape.com
945019d1be More progress on marshallers of primative types.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99205 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-13 19:55:28 +00:00
rayw%netscape.com
c23915b75e Fixed signatures of marshaller and unmarshaller to be more precise.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99148 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-13 00:39:11 +00:00
rayw%netscape.com
05c64c1c84 Better dispatching through TypeRegistry by type.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99143 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 23:15:30 +00:00
rayw%netscape.com
f5eacca3bf Added prefix reverse lookup method per level 2.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99138 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 21:07:03 +00:00
rayw%netscape.com
063b93702c forgot to increment iterators when comparing strings.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99133 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 18:54:17 +00:00
rayw%netscape.com
f859df79cf Cleaned up and implemented QName to UName translation.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99132 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 18:50:25 +00:00
rayw%netscape.com
4298e43fe6 Added StartsWith convenience string function.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99129 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 17:51:43 +00:00
rayw%netscape.com
8290529258 Added scope argument for marshalling to provide some context in DOM case.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99128 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 16:24:28 +00:00
rayw%netscape.com
d4c9b26f98 Missing error test.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98857 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-07 02:29:29 +00:00
rayw%netscape.com
e3fbe1306f Small fix.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98855 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-07 01:47:50 +00:00
rayw%netscape.com
c38912432f Added much fancier unwrapping of wrapped natives.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98854 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-07 01:43:59 +00:00
rayw%netscape.com
5e99220d9a Wrap native objects that have no other JS type.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98844 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-07 00:31:31 +00:00
rayw%netscape.com
f970f5fa83 Make Javascript value property automatically adapt literal nodes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98817 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-06 16:38:45 +00:00
rayw%netscape.com
5997698812 Added reverse resolution of namespaces (no actual method, yet.)
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98759 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-06 01:32:11 +00:00
rayw%netscape.com
3cbdb694bf Lots of fixes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98740 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 23:50:17 +00:00
rayw%netscape.com
87a6f32dd2 Added actorURI to parameter.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98692 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 19:18:34 +00:00
rayw%netscape.com
3767a96323 Eliminated header.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98691 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 19:12:54 +00:00
rayw%netscape.com
2833b5643a Added a header object to encapsulate headers.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98689 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 18:51:13 +00:00
rayw%netscape.com
36873e3a8a Supplied missing setAsStruct.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98674 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 17:04:14 +00:00
rayw%netscape.com
8038aa47fc Eliminated #iid type of SOAP parameter.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98673 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 16:38:02 +00:00
rayw%netscape.com
1b8fa049b7 Handled some extra cases better.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98654 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-04 20:25:12 +00:00
rayw%netscape.com
9b232ccf63 Reverted js type to be struct type.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98653 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-04 19:53:12 +00:00
rayw%netscape.com
2ed2a24a15 Minor fixes from code review.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98644 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-04 18:51:24 +00:00
rayw%netscape.com
fa3afd301e Added schemaID to marshalling calls.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98597 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-04 00:55:00 +00:00
rayw%netscape.com
b5f8f8b280 Added call marshaller.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98575 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 21:51:47 +00:00
rayw%netscape.com
2f8fb4e18e Somehow file got lost.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98564 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 17:10:16 +00:00
rayw%netscape.com
28510b8765 Added class and contract ID for soap struct.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98558 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 12:49:25 +00:00
rayw%netscape.com
d1874fd390 Added schemaType for more control of serialization.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98557 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 12:38:00 +00:00
rayw%netscape.com
fbb15c34df Added JS property getter/setter.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98519 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 01:57:39 +00:00
rayw%netscape.com
c972ffe9ba Added generic object to represent SOAP struct.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98502 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 00:35:06 +00:00
rayw%netscape.com
d664af31f8 Changed Enumerator to SimpleEnumerator
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98471 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-02 21:14:15 +00:00
rayw%netscape.com
f52285f36f Changed nsLiteralString to nsDependentString
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98465 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-02 20:24:48 +00:00
rayw%netscape.com
f04bae5686 Modified adapter marshal/unmarshal to properly derive this pointer.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95604 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-21 18:34:57 +00:00
rayw%netscape.com
b194997c23 Added JS compatibility for marshalling and unmarshalling of Message.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95261 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-17 16:39:52 +00:00
rayw%netscape.com
4b48f91a20 eliminated js stuff from utils.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95251 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-17 11:45:14 +00:00
rayw%netscape.com
7c8eb29757 Fixes to make it compile on landed DOM branch.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95250 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-17 11:13:19 +00:00
rayw%netscape.com
6a4c8c43e4 Fixes, addition of struct.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95249 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-17 11:12:46 +00:00
rayw%netscape.com
02b3b1eea4 Comment out uncompilable stuff.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91908 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-10 22:55:23 +00:00
rayw%netscape.com
ec9c7644b1 Put back to cut to xpconnect branch.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91896 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-10 18:49:24 +00:00
rayw%netscape.com
e935d2168c Noscripted methods to be overloaded for JS.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91895 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-10 18:48:27 +00:00
rayw%netscape.com
c5af273d98 Added methods.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91787 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 23:03:15 +00:00
rayw%netscape.com
30313dad10 Added default encoder, el;iminated JS response listener.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91786 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 22:56:24 +00:00
rayw%netscape.com
af73391209 Eliminated class IDs that probably will not be needed.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91785 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 22:55:42 +00:00
rayw%netscape.com
ccdf7fa709 Added type registry logic.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91777 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 21:32:10 +00:00
rayw%netscape.com
89b17c4b68 Latest fixes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91768 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 20:27:20 +00:00
rayw%netscape.com
f8a8ff476b Eliminated encoder includes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91698 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-08 18:40:10 +00:00
rayw%netscape.com
0f49a6c14d Fixed methods pertaining to converting to / from JavaScript values.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91697 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-08 18:36:21 +00:00
rayw%netscape.com
d915eac613 Eliminated default types from message.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91655 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-07 12:51:06 +00:00
rayw%netscape.com
cea595d018 Changes to marshalling / unmarshalling
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91654 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-07 12:48:20 +00:00
rayw%netscape.com
ef58546285 Major changes to marshalling / unmarshalling.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91653 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-07 12:47:56 +00:00
rayw%netscape.com
accd0fc6f2 Fixed inheritance and other issues
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91604 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 23:48:17 +00:00
rayw%netscape.com
83cb05e038 Eliminated generated fault idl.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91592 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 21:33:37 +00:00
rayw%netscape.com
56d1f4013d Eliminated generatedFault boolean.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91591 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 21:33:03 +00:00
rayw%netscape.com
4ebd0afc6a Added nsSOAPJSValue basic class to start supporting that.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91582 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 17:40:05 +00:00
rayw%netscape.com
f494eac05c Fixed bad manual string conversion.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91578 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 15:01:15 +00:00
rayw%netscape.com
b71e0fb70d Took a first cut at nsSOAPParameters, which needed new strings.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91576 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 14:37:40 +00:00
rayw%netscape.com
5d4865dae4 Fixed nsSOAPUtils and nsSOAPFault to use DOMStrings and not use
GetElementsByTagName, and better adapted existing work to nsSOAPUtils


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91573 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 12:19:29 +00:00
rayw%netscape.com
e5524451bc Oops, checked in uncompiled files. Minor misspellings.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91531 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 00:48:11 +00:00
rayw%netscape.com
ff9050d3f4 Fixed memory leaks and incorrect protected static declaration.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91530 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 00:45:07 +00:00
rayw%netscape.com
4be8d0eeec First check in that might actually be complete (for now).
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91497 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 22:37:37 +00:00
rayw%netscape.com
d080ca9d5f I fixed a bunch of minor things and major on marshall/unmarshall calls.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91496 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 22:36:53 +00:00
rayw%netscape.com
26f06043ba Moved actionURI to message.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91458 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 13:40:32 +00:00
rayw%netscape.com
ea12749483 Movec action back to message, since it makes it much easier for marshallers
and unmarshallers.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91457 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 13:35:52 +00:00
rayw%netscape.com
0ea210ce81 First stab at a shell response class.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91456 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 13:29:29 +00:00
rayw%netscape.com
6741f7a847 Added new version of nsSOAPMessage implementation, as only working file
in the directory thus far.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91453 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 12:44:08 +00:00
rayw%netscape.com
14f3c13cc2 Removed in new version of SOAP APIs.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91308 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-04 15:01:12 +00:00
rayw%netscape.com
d485fb8f40 New file added for new APIs.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91307 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-04 14:59:18 +00:00
rayw%netscape.com
fb1ca8255a SOAP branch for new version of APIs.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91306 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-04 14:58:24 +00:00
(no author)
b356164ebc This commit was manufactured by cvs2svn to create branch
'SOAP_20010403_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@88949 18797224-902f-48f8-a5cc-f745e15eee43
2001-03-08 08:05:07 +00:00
284 changed files with 12572 additions and 72385 deletions

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
/**
* This interface permits attachment of SOAP attachments.
*/
[scriptable, uuid(6192dcbe-1dd2-11b2-81ad-a4597614c4ae)]
interface nsISOAPAttachments : nsISupports {
/**
* Get the attachment associated with a particular identifier.
*
* @param aIdentifier The identifier of the attachment to be accessed.
*
* Appropriate return(s) must be identified.
*/
void getAttachment(in AString aIdentifier);
/**
* Attach an attachment to the message.
*
* Appropriate argument(s) must be identified.
*
* @return The identifier of the attachment, to be referenced in SOAP encoding
*/
AString attach();
};

View File

@@ -0,0 +1,90 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPMessage.idl"
interface nsISOAPResponse;
interface nsISOAPResponseListener;
/**
* This interface is a convenience extension of the basic SOAP message,
* which handles common patterns of calling, such as providing an
* action URI in the HTTP header, locating and invoking the appropriate
* transport based upon the protocol of the transportURI, and
* automatically recieving the result in a new nsISOAPResponse object
* which recieves an XML message.
*/
[scriptable, uuid(a8fefe40-52bc-11d4-9a57-000064657374)]
interface nsISOAPCall : nsISOAPMessage {
/**
* The URI to which the message will be sent, identifying the
* transport and transport-specific information about the
* destination.
* This does not have to match the <code>targetObjectURI</code>.
*/
attribute AString transportURI;
/**
* Synchronously invoke the call. The method returns only when
* we receive a response (or an error occurs). The
* <code>transportURI</code> must have been set, the
* parameter list (even if empty) must have been encoded,
* and the transportURI must use some known protocol. A
* synchronous call assumes that there will be exactly one
* response per call.
*
* If not, an error is returned in the status of the response.
*
* @returns The SOAP response
*/
nsISOAPResponse invoke();
/**
* Asynchronously invoke the call. At this point, the document
* rooted by the Envelope element is encoded to form the body
* of the SOAP message. The method returns immediately, and the
* listener is invoked when we eventually receive a response
* (or error or successful completion). The
* <code>transportURI</code> must have been set, the
* parameter list (even if empty) must have been encoded,
* and the transportURI must use some known protocol.
*
* If not, an error is returned in the status of the response.
*
* @param aListener Handler to be invoked asynchronously after the
* response is recieved. Should be null if no response is
* expected.
*/
void asyncInvoke(in nsISOAPResponseListener aListener);
};
%{ C++
#define NS_SOAPCALL_CID \
{ /* 87d21ec0-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec0, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPCALL_CONTRACTID \
"@mozilla.org/xmlextras/soap/call;1"
%}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsISOAPEncoding;
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPAttachments;
/**
* This interface supplies decoding of a specific
* part of a message XML DOM into appropriate objects
* for the script or application.
*/
[scriptable, uuid(4c2e02ae-1dd2-11b2-b1cd-c79dea3d46db)]
interface nsISOAPDecoder : nsISupports {
/**
* Decode the source DOM node
*
* @param aEncodings The encodings used to decode
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The DOM node to be decoded.
*
* @param aSchemaType The schema type of the source DOM node
*
* @param aAttachments Dispenses any attachments.
*
* @return The decoded variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsISOAPEncoding aEncoding,
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsISOAPEncoding;
interface nsIVariant;
interface nsIDOMElement;
interface nsISOAPAttachments;
/**
* This interface permits encoding of variants.
*/
[scriptable, uuid(fc33ffd6-1dd1-11b2-8750-fa62430a38b4)]
interface nsISOAPEncoder : nsISupports {
/**
* Encode the source variant.
*
* @param aEncodings The encodings to be used.
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The variant to be encoded.
*
* @param aNamespaceURI The namespace of the thing being coded
*
* @param aName The name of the thing being coded
*
* @param aSchemaType The schema type of the thing being encoded
*
* @param aDestination The node scope, if any, where the result
* will live. If this is null, then the result must be
* explicitly attached to the message.
*
* @return element which was inserted.
*
* @param aAttachments Accumulates any attachments.
*/
nsIDOMElement encode(
in nsISOAPEncoding aEncoding,
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
};

View File

@@ -0,0 +1,184 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsIDOMElement;
interface nsISOAPEncoder;
interface nsISOAPDecoder;
interface nsISOAPMessage;
interface nsIVariant;
interface nsISOAPAttachments;
interface nsISchemaCollection;
/**
* This interface keeps track of all the known types and how
* each should be encoded (by type) or decoded (by
* schema type)
*/
[scriptable, uuid(9ae49600-1dd1-11b2-877f-e62f620c5e92)]
interface nsISOAPEncoding : nsISupports {
/**
* The name of the encoding as it is known to SOAP.
*/
readonly attribute AString styleURI;
/**
* Get an alternative encoding.
*
* @param aStyleURI The style URI of the alternative encoding style.
*
* @param aCreateIf If true, then create the alternative style if it
* does not already exist, otherwise return the existing encoding.
*
* @return The alternative encoding which corresponds to the
* specified styleURI, or null if the spefied alternative encoding
* does not exist and it was not requested that it be created.
*/
nsISOAPEncoding getStyle(
in AString aStyleURI,
in boolean aCreateIf);
/**
* Set an encoder in the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @param aEncoder The encoder to be specified or null to eliminate
* the encoder.
*
* @return Old encoder registered under that type in the encoding, which
* should be kept by the new encoder if it is to be called back.
*/
void setEncoder(in AString aSchemaNamespaceURI, in AString aSchemaType,
in nsISOAPEncoder aEncoder);
/**
* Get an encoder from the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @return The encoder.
*/
nsISOAPEncoder getEncoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
/**
* Set a decoder in the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @param aDecoder The decoder to be specified or null to eliminate
* the decoder.
*
* @return Old decoder registered under that type in the encoding, which
* should be kept by the new decoder if it is to be called back.
*/
void setDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType,
in nsISOAPDecoder aDecoder);
/**
* Get a decoder from the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @return The decoder.
*/
nsISOAPDecoder getDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
attribute nsISOAPEncoder defaultEncoder;
attribute nsISOAPDecoder defaultDecoder;
attribute nsISchemaCollection schemaCollection;
/**
* Encode the source variant
*
* @param aEncodings The encodings to be used.
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The variant to be encoded, soon to become a variant
*
* @param aNamespaceURI The namespace of the thing being coded
*
* @param aName The name of the thing being coded
*
* @param aSchemaType The schema type of the thing being encoded
*
* @param aDestination The node scope where the result will live.
*
* @param aAttachments Accumulates any attachments.
*
* @return The element which was inserted and encoded.
*/
nsIDOMElement encode(
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
/**
* Decode the source DOM node
*
* @param aEncodings The encodings used to decode
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The DOM node to be decoded.
*
* @param aSchemaType The schema type of the source DOM node
*
* @param aAttachments Dispenses any attachments.
*
* @return The decoded variant, soon to become a variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};
%{ C++
#define NS_DEFAULTSOAPENCODER_CID \
{ /* 06fb035c-1dd2-11b2-bc30-f6d8e314d6b9 */ \
0x06fb035c, 0x1dd2, 0x11b2, \
{0xbc, 0x30, 0xf6, 0xd8, 0xe3, 0x14, 0xd6, 0xb9} }
#define NS_SOAPENCODING_CONTRACTID_PREFIX \
"@mozilla.org/xmlextras/soap/encoding;1?uri="
#define NS_DEFAULTSOAPENCODER_CONTRACTID \
NS_SOAPENCODING_CONTRACTID_PREFIX "http://schemas.xmlsoap.org/soap/encoding/"
%}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
/**
* This interface conveniently interprets information about a fault
* that has been returned in a response message.
*
*/
[scriptable, uuid(99ec6694-535f-11d4-9a58-000064657374)]
interface nsISOAPFault : nsISupports {
/**
* The DOM element representing the fault in the response SOAP message.
* This must be set for the rest of the interface to function correctly.
*/
attribute nsIDOMElement element;
/**
* The fault code
*/
readonly attribute AString faultCode;
/**
* The fault string
*/
readonly attribute AString faultString;
/**
* The fault actor if one was specified.
*/
readonly attribute AString faultActor;
/**
* The DOM element representing the fault details
*/
readonly attribute nsIDOMElement detail;
};
%{ C++
#define NS_SOAPFAULT_CID \
{ /* 87d21ec1-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec1, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPFAULT_CONTRACTID \
"@mozilla.org/xmlextras/soap/fault;1"
%}

View File

@@ -0,0 +1,96 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary header block to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
*/
[scriptable, uuid(063d4a4e-1dd2-11b2-a365-cbaf1651f140)]
interface nsISOAPHeaderBlock : nsISupports {
/**
* The namespace URI of the header block. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the header block. If the header block is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The actor URI of the header block.
*/
attribute AString actorURI;
/**
* The encoding that was / will be applied to the
* header block.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* header block.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this header block.
* If this is set, value becomes a computed attribute
* which is produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this header block. If this is set, element becomes null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message.
*/
attribute nsISOAPAttachments attachments;
};
%{ C++
#define NS_SOAPHEADERBLOCK_CID \
{ /* 5ad0eace-1dd2-11b2-a260-ff42edcaedb3 */ \
0x5ad0eace, 0x1dd2, 0x11b2, \
{0xa2, 0x60, 0xff, 0x42, 0xed, 0xca, 0xed, 0xb3} }
#define NS_SOAPHEADERBLOCK_CONTRACTID \
"@mozilla.org/xmlextras/soap/headerblock;1"
%}

View File

@@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsIDOMElement;
interface nsISOAPEncoding;
interface nsISOAPHeaderBlock;
interface nsISOAPParameter;
interface nsIVariant;
/**
* This interface controls all SOAP messages. It permits easy
* construction of a message, typically through encoding of
* parameters and certain properties settable on this interface
* or through deserialization of a transport stream. It
* permits easy processing of a message typically through
* decoding of parameters and certain properties available
* on this interface. It also encapsulates protocol information
* interpreted by the transport.
*/
[scriptable, uuid(3970815e-1dd2-11b2-a475-db4dac6826f1)]
interface nsISOAPMessage : nsISupports {
/**
* The document which captures the message, if any. A simple
* sending application passes parameters to the method
* encodeSOAPParameters, which calls SOAP encoders
* to construct this document along with all contained elements.
*
* But an application may create and set the message directly
* instead of invoking encodeSOAPParameters to use encoders
* or access and manipulate the message after it has been
* constructed by encodeSOAPParameters. If the message has
* not been set, invoking a call will fail. A message reciever
* may also use this accessor to get the document to avoid using
* decoders.
*/
attribute nsIDOMDocument message;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP envelope from the document. DOM methods may be used to
* access, add, or modify attributes of the envelope.
*
* If the message attribute is null or is not a document containing
* a root soap envelope element, then this will be null.
*/
readonly attribute nsIDOMElement envelope;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP header from the envelope. DOM methods may be used to
* access, add, or modify attributes or elements of the header.
*
* If the envelope attribute is null or does not contain a SOAP header
* element type, then this will be null.
*/
readonly attribute nsIDOMElement header;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP body from the envelope. DOM methods may be used to
* access, add, or modify attributes or elements of the body.
*
* If the envelope attribute is null or does not contain a SOAP body
* element type, then this will be null.
*/
readonly attribute nsIDOMElement body;
/**
* The name of the method being invoked. The methodName is set
* during encoding as the tagname of the single child of body
* of RPC-style messages. When there is no encoded message
* this will be null. The value of this attribute for
* document-style messages may be non-null but should be
* ignored. It is up to the application to know whether the
* message is RPC-style or document style because the SOAP
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString methodName;
/**
* The target object on which the method is being invoked. This URI
* is set during encoding as the namespace to qualify the tagname
* of the single child of body of RPC-style messages. When there
* is no encoded message, this will be null. The value of this
* attribute for document-style messages may be non-null but should
* be ignored. It is up to the application to know whether the
* message is RPC-style or document style because the SOAP
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString targetObjectURI;
/**
* Encodes the specified parameters into this message, if
* this message type supports it.
*
* @param aMethodName The name of the method being invoked
* for rpc-style messages. For document-style messages,
* this must be null.
*
* @param aTargetObjectURI The name of the target object
* for rpc-style messages. For document-style messages,
* this must be null.
*
* @param aHeaderBlockCount Number of header blocks in array to be
* encoded. Must be 0 if header block array is null.
*
* @param aHeaderBlocks Array of header blocks to be encoded, which
* may be null if there are no header blocks.
*
* @param aParameterCount Number of parameters in array
* to be encoded. Must be 0 if parameter array is null.
*
* @param aParameters An array of parameters to be
* encoded, which may null if there are no parameters.
*/
void encode(
in AString aMethodName, in AString aTargetObjectURI,
in PRUint32 aHeaderBlockCount,
[array, size_is(aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks,
in PRUint32 aParameterCount,
[array, size_is(aParameterCount)] in nsISOAPParameter aParameters);
/**
* Gathers the header blocks of a message so that they can be
* accessed by a recipient.
*
* @param aCount Integer to receive the length of the list
* of header blocks.
*
* @return Array of header blocks found in the message.
*/
void getHeaderBlocks(out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks);
/**
* Gathers the parameters of a message so that they can be
* accessed by a recipient.
*
* @param aDocumentStyle If true, then the parameters
* are looked for treating the message as a document
* style message, otherwise it treated as an RPC-style
* message.
*
* @param aCount Integer to receive the length of the list
* of parameters.
*
* @return Array of parameters found in the message.
*/
void getParameters(in boolean aDocumentStyle,
out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPParameter aParameters);
/**
* The primary encoding of the message, which is established
* at the envelope and used unless overridden. By default,
* this is the SOAP encoding, which may be locally modified
* or used to obtain alternative encodings, which may be
* locally modified, but it may be set to an encoding that
* is shared, or it may be set to null, in which case all
* non-literal header blocks and parameters must specify an
* encoding.
*/
attribute nsISOAPEncoding encoding;
/**
* An optional URI that can be used to add a SOAPAction HTTP
* header field. If this attribute is NULL (the default case),
* no SOAPAction header will be added.
*/
attribute AString actionURI;
};

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary parameter to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
*/
[scriptable, uuid(99ec6690-535f-11d4-9a58-000064657374)]
interface nsISOAPParameter : nsISupports {
/**
* The namespace URI of the parameter. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the parameter. If the parameter is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The encoding that was / will be applied to the
* parameter.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* parameter.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this parameter.
* If this is set, value becomes a computed attribute
* which may be produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this parameter. If this is set, element becomes
* null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message
* that may be needed to decode the parameter.
*/
attribute nsISOAPAttachments attachments;
};
%{ C++
#define NS_SOAPPARAMETER_CID \
{ /* 87d21ec2-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec2, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPPARAMETER_CONTRACTID \
"@mozilla.org/xmlextras/soap/parameter;1"
%}

View File

@@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPCall.idl"
interface nsISOAPParameter;
interface nsISOAPFault;
/**
* This is an extension of a message which contains extra functions
* such as tracking, where appropriate, the original call that
* produced the response message, identifying the fault, if any,
* and supplying the return value.
*/
[scriptable, uuid(99ec6691-535f-11d4-9a58-000064657374)]
interface nsISOAPResponse : nsISOAPMessage {
/**
* The message which generated this response. There is no guarantee
* that the message has not been modified since the original call
* occurred. This is set automatically when invoking a call that
* returns this response. This must also be set by a call processor
* so that the transport can return a response to the correct caller.
*/
attribute nsISOAPCall respondingTo;
/**
* The fault returned in the response, if one was generated. NULL
* if there was no fault. This does not rely on the response
* parameters having been deserialized.
*/
readonly attribute nsISOAPFault fault;
};
%{ C++
#define NS_SOAPRESPONSE_CID \
{ /* 87d21ec3-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec3, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPRESPONSE_CONTRACTID \
"@mozilla.org/xmlextras/soap/response;1"
%}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPCall;
interface nsISOAPResponse;
/**
* This interface represents a response handler to be invoked whenever
* a response of a particular call is recieved and when no more
* responses are expected.
*/
[scriptable, uuid(99ec6692-535f-11d4-9a58-000064657374)]
interface nsISOAPResponseListener : nsISupports {
/**
* This method is invoked when we receive an asynchronous response to
* a SOAP message. The listener is registered as part of the original
* asynchronous call invocation.
*
* @param aResponse The decoded version of the response. If an
* error occurred transmitting the response, the status field
* of the response will contain an error code. The last call
* to the listener may contain a null response, which should
* only be interpreted as an error if your call expected more
* results than it got. If the service or the transport
* do not know whether to expect more results, then setting
* the last parameter true may only be possible after the
* last response has already been delivered.
*
* @param aLast True if this is the last call to the listener.
*
* @return True to make this the last call to the listener, even
* if last was not true. Calls which expect a single response
* should return true upon receiving that response to avoid
* possibly recieving another callback with a null response
* indicating that the last response was already sent.
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in unsigned long status, in boolean aLast);
};

View File

@@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPMessage;
interface nsISOAPResponseListener;
/**
* This interface describes a service which may be
* applied to incoming messages. The service is
* responsible for determining whether the message
* is one that it should process and rejecting it
* if it is not. Services may be chained.
*/
[scriptable, uuid(9927fa40-1dd1-11b2-a8d1-857ad21b872c)]
interface nsISOAPService : nsISupports {
/**
* Configuration object that may contain more info on the service
*/
attribute nsISupports configuration;
/**
* Process an incoming message.
*
* @param aMessage message to be processed
*
* @param aListener listener to which to report results
*
* @return True if the message will be handled, false if
* it should be given to some other service or fail.
* In case of failure, a more detailed status will be
* recorded in the message.
*/
boolean process(in nsISOAPMessage aMessage,
in nsISOAPResponseListener aListener);
};
%{ C++
#define NS_SOAPJSSERVICE_CID \
{ /* 26a41df2-1dd2-11b2-9f29-909e637afa0e */ \
0x26a41df2, 0x1dd2, 0x11b2, \
{0x9f, 0x29, 0x90, 0x9e, 0x63, 0x7a, 0xfa, 0x0e} }
#define NS_SOAPJSSERVICE_CONTRACTID \
"@mozilla.org/xmlextras/soap/jsservice;1"
%}

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsISOAPService;
interface nsISOAPEncodingRegistry;
/**
* This interface represents a registry of SOAP services.
* This registry recieves transports to listen for messages
* and services to hand the messages to. Service registries
* may be created as required. Destroying a service registry
* stops the registry's action. To temporarily register
* services, create a new registry. For proper order of
* listening precedence, registries should be destroyed
* in reverse order. Otherwise, a listening priority
* would be required.
*/
[scriptable, uuid(9790d6bc-1dd1-11b2-afe0-bcb310c078bf)]
interface nsISOAPServiceRegistry {
/**
* Process a configuration and add the resulting sources
* and services. This will fail if errors occur during
* processing of the configuration.
*
* @param aConfiguration Root element of configuration XML.
*/
boolean addConfiguration(in nsIDOMElement aConfiguration);
/**
* Add a transport to be serviced by the registered services.
* This will fail if the specified source was already added
* with the same setting of the capture flag.
*
* @param aTransport string specifying the transport to supply
* messages for the service.
*
* @param aCapture True if capturing before later declarations
*/
void addSource(in AString aTransport, in boolean aCapture);
/**
* Add a service to service the registered transports. This
* will fail if the specified service was already added.
*
* @param aService Service to be serviced.
*/
void addService(in nsISOAPService aService);
/**
* Registry identifying how to encode and decode
* messages containing specific types, automatically
* added to messages sent to services in this
* registry.
*/
attribute nsISOAPEncodingRegistry encodings;
};
%{ C++
#define NS_SOAPSERVICEREGISTRY_CID \
{ /* 3869184e-1dd2-11b2-aa36-d8333498043a */ \
0x3869184e, 0x1dd2, 0x11b2, \
{0xaa, 0x36, 0xd8, 0x33, 0x34, 0x98, 0x04, 0x3a} }
#define NS_SOAPSERVICEREGISTRY_CONTRACTID \
"@mozilla.org/xmlextras/soap/serviceregistry;1"
#define NS_SOAPDEFAULTSERVICEREGISTRY_CID \
{ /* 9120a01e-1dd2-11b2-a61f-906766927a4f */ \
0x9120a01e, 0x1dd2, 0x11b2, \
{0xa6, 0x1f, 0x90, 0x67, 0x66, 0x92, 0x7a, 0x4f} }
#define NS_SOAPDEFAULTSERVICEREGISTRY_CONTRACTID \
"@mozilla.org/xmlextras/soap/defaultserviceregistry;1"
%}

View File

@@ -0,0 +1,102 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPTransportListener;
interface nsISOAPCall;
interface nsISOAPResponse;
interface nsISOAPResponseListener;
[scriptable, uuid(99ec6695-535f-11d4-9a58-000064657374)]
interface nsISOAPTransport : nsISupports {
/**
* Send the specified message to the specified destination.
* This will fail if synchronous calls are not supported or if there is any
* failure in the actual message exchange. Failure of the call itself will be
* contained in the response.
*
* @param aCall Actual message to be sent.
*
* @param aResponse Message to be recieved. Calling synchronously assumes that
* exactly one response is expected.
*/
void syncCall( in nsISOAPCall aCall,
in nsISOAPResponse aResponse);
/**
* Send the specified message to the specified destination synchronously waiting
* for completion and any response.
* This will fail if there is any failure in the setup of the message exchange.
* Later errors will only be known through the response listener. Failures of the
* call itself will be contained in the response passed to the response listener.
*
* @param aCall Actual message to be sent.
*
* @param aListener Handler to be invoked (single threaded) as each response is
* received and finally with null. If specified as null, no responses are returned.
*
* @param response Message to recieve response and be handled by listener. May be
* null if listener is null.
*/
void asyncCall(in nsISOAPCall aCall,
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);
/**
* Add listener for unsolicited messages arriving on the transport. Listeners
* are provided with the opportunity to accept and process messages. Typically
* a listener will be a service dispatcher. Listeners will be invoked in the
* reverse order of declaration, allowing more local service dispatchers to
* temporarily override permanent service dispatchers. This will fail if the
* desired listener was already added to the transport with the specified
* capture flag or if the transport does not support incoming messages.
*
* @param aListener The listener to recieve unsolicited messages from the
* transport.
*
* @param aCapture True if the listener should capture the message before
* later-declared services.
*/
void addListener(in nsISOAPTransportListener aListener, in boolean aCapture);
/**
* Remove listener for unsolicited messages arriving on the transport. This
* will fail if the specified listener was not added with the specified
* capture setting.
*
* @param aListener The listener to stop from recieving unsolicited messages
* from the transport.
*
* @param aCapture True if the listener was added to capture the message before
* later-declared services (must be specified to remove, since a listener
* may be registered as both).
*/
void removeListener(in nsISOAPTransportListener aListener, in boolean aCapture);
};
%{ C++
#define NS_SOAPTRANSPORT_CONTRACTID \
"@mozilla.org/xmlextras/soap/transport;1"
#define NS_SOAPTRANSPORT_CONTRACTID_PREFIX NS_SOAPTRANSPORT_CONTRACTID "?protocol="
%}

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsISOAPMessage;
/**
* This interface recieves control when an unsolicited transport
* is recieved on a transport.
*/
[scriptable, uuid(99ec6696-535f-11d4-9a58-000064657374)]
interface nsISOAPTransportListener : nsISupports {
/**
* This method is invoked when an unsolicited message is
* recieved. First all listeners are tried in the order declared
* with the capture flag set. Then all listeners are tried in
* the reverse order declared with the capture flag clear.
*
* @param aMessage Actual message.
*
* @param aCapture True if the listener is being permitted to gain
* control before all later-added listeners.
*
* @return true if message is handled, false if it was not
*/
boolean handleMessage(in nsISOAPMessage aMessage, in boolean aCapture);
};

View File

@@ -0,0 +1,31 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,52 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xmlextras
LIBRARY_NAME = xmlextrassoap_s
REQUIRES = xpcom string caps dom js widget xpconnect necko schema
CPPSRCS = \
nsDefaultSOAPEncoder.cpp\
nsHTTPSOAPTransport.cpp \
nsSOAPCall.cpp \
nsSOAPEncoding.cpp \
nsSOAPFault.cpp \
nsSOAPHeaderBlock.cpp \
nsSOAPMessage.cpp \
nsSOAPParameter.cpp \
nsSOAPResponse.cpp \
nsSOAPUtils.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
#override NO_SHARED_LIB=1
#override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsDefaultSOAPEncoder_h__
#define nsDefaultSOAPEncoder_h__
#include "nsSOAPEncoding.h"
class nsDefaultSOAPEncoder : public nsSOAPEncoding
{
public:
nsDefaultSOAPEncoder();
};
#endif

View File

@@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsHTTPSOAPTransport.h"
#include "nsIComponentManager.h"
#include "nsIDOMDocument.h"
#include "nsString.h"
#include "nsSOAPUtils.h"
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsIDOMEventTarget.h"
nsHTTPSOAPTransport::nsHTTPSOAPTransport()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransport::~nsHTTPSOAPTransport()
{
}
NS_IMPL_ISUPPORTS1_CI(nsHTTPSOAPTransport, nsISOAPTransport)
/* void syncCall (in nsISOAPCall aCall, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse *aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
}
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMDocument> messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_FALSE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
request->GetStatus(&rv);
if (NS_FAILED(rv)) return rv;
if (aResponse) {
nsCOMPtr<nsIDOMDocument> response;
rv = request->GetResponseXML(getter_AddRefs(response));
if (NS_FAILED(rv)) return rv;
rv = aResponse->SetMessage(response);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener
{
public:
nsHTTPSOAPTransportCompletion();
virtual ~nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
protected:
nsCOMPtr<nsISOAPCall> mCall;
nsCOMPtr<nsISOAPResponse> mResponse;
nsCOMPtr<nsIXMLHttpRequest> mRequest;
nsCOMPtr<nsISOAPResponseListener> mListener;
};
NS_IMPL_ISUPPORTS1(nsHTTPSOAPTransportCompletion, nsIDOMEventListener)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransportCompletion::~nsHTTPSOAPTransportCompletion()
{
}
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent* aEvent)
{
nsresult rv;
mRequest->GetStatus(&rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv)) {
rv = mResponse->SetMessage(document);
}
}
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, (PRInt32)rv, PR_TRUE, &c);
return NS_OK;
}
/* void asyncCall (in nsISOAPCall aCall, in nsISOAPResponseListener aListener, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponseListener *aListener, nsISOAPResponse *aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(request, &rv);
if (NS_FAILED(rv)) return rv;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIDOMEventListener> listener = new nsHTTPSOAPTransportCompletion();
if (!listener) return NS_ERROR_OUT_OF_MEMORY;
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMDocument> messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_TRUE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
eventTarget->AddEventListener(NS_LITERAL_STRING("load"), listener, PR_FALSE);
eventTarget->AddEventListener(NS_LITERAL_STRING("error"), listener, PR_FALSE);
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
/* void addListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::AddListener(nsISOAPTransportListener *aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void removeListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::RemoveListener(nsISOAPTransportListener *aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsHTTPSOAPTransport_h__
#define nsHTTPSOAPTransport_h__
#include "nsISOAPTransport.h"
#include "nsIXMLHttpRequest.h"
#include "nsIDOMEventListener.h"
#include "nsISOAPTransportListener.h"
#include "nsCOMPtr.h"
class nsHTTPSOAPTransport : public nsISOAPTransport
{
public:
nsHTTPSOAPTransport();
virtual ~nsHTTPSOAPTransport();
NS_DECL_ISUPPORTS
// nsISOAPTransport
NS_DECL_NSISOAPTRANSPORT
};
#define NS_HTTPSOAPTRANSPORT_CID \
{ /* d852ade0-5823-11d4-9a62-00104bdf5339 */ \
0xd852ade0, 0x5823, 0x11d4, \
{0x9a, 0x62, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_HTTPSOAPTRANSPORT_CONTRACTID NS_SOAPTRANSPORT_CONTRACTID_PREFIX "http"
#endif

View File

@@ -0,0 +1,187 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsSOAPUtils.h"
#include "nsISOAPTransport.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
/////////////////////////////////////////////
//
//
/////////////////////////////////////////////
nsSOAPCall::nsSOAPCall()
{
}
nsSOAPCall::~nsSOAPCall()
{
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPCall, nsISOAPMessage, nsISOAPCall)
NS_IMPL_ADDREF_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPCall)
NS_INTERFACE_MAP_ENTRY(nsISOAPCall)
NS_IMPL_QUERY_CLASSINFO(nsSOAPCall)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* attribute DOMString transportURI; */
NS_IMETHODIMP nsSOAPCall::GetTransportURI(nsAWritableString & aTransportURI)
{
NS_ENSURE_ARG_POINTER(&aTransportURI);
aTransportURI.Assign(mTransportURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPCall::SetTransportURI(const nsAReadableString & aTransportURI)
{
mTransportURI.Assign(aTransportURI);
return NS_OK;
}
nsresult
nsSOAPCall::GetTransport(nsISOAPTransport** aTransport)
{
NS_ENSURE_ARG_POINTER(aTransport);
nsresult rv;
nsCOMPtr<nsIURI> uri;
nsXPIDLCString protocol;
nsCString transportURI(ToNewCString(mTransportURI));
rv = NS_NewURI(getter_AddRefs(uri), transportURI.get());
if (NS_FAILED(rv)) return rv;
uri->GetScheme(getter_Copies(protocol));
nsCAutoString transportContractid;
transportContractid.Assign(NS_SOAPTRANSPORT_CONTRACTID_PREFIX);
transportContractid.Append(protocol);
nsCOMPtr<nsISOAPTransport> transport = do_GetService(transportContractid.get(), &rv);
if (NS_FAILED(rv)) return rv;
*aTransport = transport.get();
NS_ADDREF(*aTransport);
return NS_OK;
}
/* nsISOAPResponse invoke (); */
NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response;
response = new nsSOAPResponse();
if (!response) return NS_ERROR_OUT_OF_MEMORY;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->SyncCall(this, response);
if (NS_FAILED(rv)) return rv;
return response->QueryInterface(NS_GET_IID(nsISOAPResponse), (void**)_retval);
}
/* void asyncInvoke (in nsISOAPResponseListener listener); */
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener)
{
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response;
response = new nsSOAPResponse();
if (!response) return NS_ERROR_OUT_OF_MEMORY;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->AsyncCall(this, listener, response);
return rv;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPCall::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPCall::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPCall::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPCall::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPCall_h__
#define nsSOAPCall_h__
#include "nsString.h"
#include "nsSOAPMessage.h"
#include "nsISOAPCall.h"
#include "nsISecurityCheckedComponent.h"
#include "nsISOAPTransport.h"
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsSOAPCall : public nsSOAPMessage,
public nsISOAPCall
{
public:
nsSOAPCall();
virtual ~nsSOAPCall();
NS_DECL_ISUPPORTS
// nsISOAPCall
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPCall
NS_DECL_NSISOAPCALL
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsString mTransportURI;
nsresult GetTransport(nsISOAPTransport** aTransport);
};
#endif

View File

@@ -0,0 +1,405 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsISOAPParameter.h"
#include "nsSOAPMessage.h"
#include "nsISOAPEncoder.h"
#include "nsISOAPDecoder.h"
#include "nsSOAPEncoding.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIDOMNodeList.h"
#include "nsISchema.h"
#include "nsISchemaLoader.h"
#include "nsSOAPUtils.h"
// First comes the registry which shares between associated encodings but is never seen by xpconnect.
NS_IMPL_ISUPPORTS1(nsSOAPEncodingRegistry,nsISOAPEncoding)
nsSOAPEncodingRegistry::nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding): mEncodings(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
nsAutoString style;
aEncoding->GetStyleURI(style);
nsStringKey styleKey(style);
mEncodings->Put(&styleKey, aEncoding);
/* member initializers and constructor code */
}
nsSOAPEncodingRegistry::~nsSOAPEncodingRegistry()
{
/* destructor code */
delete mEncodings;
}
nsresult nsSOAPEncodingRegistry::GetStyle(const nsAString& aStyleURI, PRBool aCreateIf, nsISOAPEncoding* * aEncoding)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(aEncoding);
nsStringKey styleKey(aStyleURI);
*aEncoding = (nsISOAPEncoding*)mEncodings->Get(&styleKey);
if (!*aEncoding)
{
nsCOMPtr<nsISOAPEncoding> defaultEncoding;
nsCAutoString encodingContractid;
encodingContractid.Assign(NS_SOAPENCODING_CONTRACTID_PREFIX);
encodingContractid.Append(NS_ConvertUCS2toUTF8(aStyleURI));
defaultEncoding = do_GetService(encodingContractid.get());
if (defaultEncoding || aCreateIf) {
*aEncoding = new nsSOAPEncoding(aStyleURI, this, defaultEncoding);
mEncodings->Put(&styleKey, *aEncoding);
}
}
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
mSchemaCollection = aSchemaCollection;
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
if (!mSchemaCollection) {
nsresult rv;
nsCOMPtr<nsISchemaLoader>loader = do_CreateInstance(NS_SCHEMALOADER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
mSchemaCollection = do_QueryInterface(loader);
if (!mSchemaCollection) return NS_ERROR_FAILURE;
}
*aSchemaCollection = mSchemaCollection;
NS_ADDREF(*aSchemaCollection);
return NS_OK;
}
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetStyleURI(nsAString & aStyleURI)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder *aEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder getEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder setDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder *aDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder getDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// Second, we create the encodings themselves.
NS_IMPL_ISUPPORTS2(nsSOAPEncoding, nsISOAPEncoding, nsISecurityCheckedComponent)
nsSOAPEncoding::nsSOAPEncoding(): mEncoders(new nsSupportsHashtable),
mDecoders(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(nsSOAPUtils::kSOAPEncodingURI);
mDefaultEncoding = do_GetService(NS_DEFAULTSOAPENCODER_CONTRACTID);
mRegistry = new nsSOAPEncodingRegistry(this);
}
nsSOAPEncoding::nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry* aRegistry, nsISOAPEncoding* aDefaultEncoding)
: mEncoders(new nsSupportsHashtable), mDecoders(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(aStyleURI);
mRegistry = aRegistry;
mDefaultEncoding = aDefaultEncoding;
}
nsSOAPEncoding::~nsSOAPEncoding()
{
/* destructor code */
delete mEncoders;
delete mDecoders;
}
nsresult nsSOAPEncoding::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
return mRegistry->SetSchemaCollection(aSchemaCollection);
}
nsresult nsSOAPEncoding::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
return mRegistry->GetSchemaCollection(aSchemaCollection);
}
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncoding::GetStyleURI(nsAString & aStyleURI)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
aStyleURI.Assign(mStyleURI);
return NS_OK;
}
/* nsISOAPEncoding getStyle (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetStyle(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(_retval);
return mRegistry->GetStyle(aStyleURI, aCreateIf, _retval);
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncoding::SetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder *aEncoder)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG(aEncoder);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
if (aEncoder) {
mEncoders->Put(&nameKey, aEncoder, nsnull);
}
else {
mEncoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPEncoder getEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncoding::GetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG_POINTER(_retval);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
*_retval = (nsISOAPEncoder*)mEncoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetEncoder(aSchemaNamespaceURI, aSchemaType, _retval);
}
return NS_OK;
}
/* nsISOAPDecoder setDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncoding::SetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder *aDecoder)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
if (aDecoder) {
mDecoders->Put(&nameKey, aDecoder, nsnull);
}
else {
mDecoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPDecoder getDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncoding::GetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG_POINTER(_retval);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
*_retval = (nsISOAPDecoder*)mDecoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetDecoder(aSchemaNamespaceURI, aSchemaType, _retval);
}
return NS_OK;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncoding::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPEncoder> encoder;
nsresult rv = GetDefaultEncoder(getter_AddRefs(encoder));
if (NS_FAILED(rv)) return rv;
if (encoder) {
return encoder->Encode(this, aSource, aNamespaceURI, aName, aSchemaType, aAttachments, aDestination,
_retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncoding::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPDecoder> decoder;
nsresult rv = GetDefaultDecoder(getter_AddRefs(decoder));
if (NS_FAILED(rv)) return rv;
if (decoder) {
return decoder->Decode(this, aSource, aSchemaType, aAttachments, _retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
NS_ENSURE_ARG_POINTER(aDefaultEncoder);
if (mDefaultEncoding && !mDefaultEncoder) {
return mDefaultEncoding->GetDefaultEncoder(aDefaultEncoder);
}
*aDefaultEncoder = mDefaultEncoder;
NS_IF_ADDREF(*aDefaultEncoder);
return NS_OK;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
mDefaultEncoder = aDefaultEncoder;
return NS_OK;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
NS_ENSURE_ARG_POINTER(aDefaultDecoder);
if (mDefaultEncoding && !mDefaultDecoder) {
return mDefaultEncoding->GetDefaultDecoder(aDefaultDecoder);
}
*aDefaultDecoder = mDefaultDecoder;
NS_IF_ADDREF(*aDefaultDecoder);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
mDefaultDecoder = aDefaultDecoder;
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPEncoding::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPEncoding::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPEncoding::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPEncoding::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPEncodingRegistry_h__
#define nsSOAPEncodingRegistry_h__
#include "nsString.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsISOAPEncoding.h"
#include "nsISOAPEncoder.h"
#include "nsISOAPDecoder.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsISchema.h"
class nsSOAPEncoding;
/* Header file */
class nsSOAPEncodingRegistry : public nsISOAPEncoding
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
nsSOAPEncodingRegistry() {}
nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding);
virtual ~nsSOAPEncodingRegistry();
protected:
nsSupportsHashtable* mEncodings;
nsCOMPtr<nsISchemaCollection> mSchemaCollection;
};
class nsSOAPEncoding : public nsISOAPEncoding,
public nsISecurityCheckedComponent
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsSOAPEncoding();
nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry * aRegistry, nsISOAPEncoding* aDefaultEncoding);
virtual ~nsSOAPEncoding();
/* additional members */
protected:
nsString mStyleURI;
nsSupportsHashtable* mEncoders;
nsSupportsHashtable* mDecoders;
nsCOMPtr<nsISOAPEncoding> mRegistry;
nsCOMPtr<nsISOAPEncoding> mDefaultEncoding;
nsCOMPtr<nsISOAPEncoder> mDefaultEncoder;
nsCOMPtr<nsISOAPDecoder> mDefaultDecoder;
};
#endif

View File

@@ -0,0 +1,154 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPFault.h"
#include "nsSOAPUtils.h"
#include "nsIDOMNodeList.h"
nsSOAPFault::nsSOAPFault(nsIDOMElement* aElement)
{
NS_INIT_ISUPPORTS();
mFaultElement = aElement;
}
nsSOAPFault::~nsSOAPFault()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPFault, nsISOAPFault, nsISecurityCheckedComponent)
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPFault::SetElement(nsIDOMElement *aElement)
{
mFaultElement = aElement;
return NS_OK;
}
NS_IMETHODIMP nsSOAPFault::GetElement(nsIDOMElement * *aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mFaultElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
/* readonly attribute wstring faultCode; */
NS_IMETHODIMP nsSOAPFault::GetFaultCode(nsAWritableString & aFaultCode)
{
NS_ENSURE_ARG_POINTER(&aFaultCode);
aFaultCode.Truncate();
nsCOMPtr<nsIDOMElement> faultcode;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultCodeTagName,
getter_AddRefs(faultcode));
if (faultcode) {
nsSOAPUtils::GetElementTextContent(faultcode, aFaultCode);
}
return NS_OK;
}
/* readonly attribute wstring faultString; */
NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAWritableString & aFaultString)
{
NS_ENSURE_ARG_POINTER(&aFaultString);
aFaultString.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultStringTagName, getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultString);
}
return NS_OK;
}
/* readonly attribute wstring faultActor; */
NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAWritableString & aFaultActor)
{
NS_ENSURE_ARG_POINTER(&aFaultActor);
aFaultActor.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultActorTagName, getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultActor);
}
return NS_OK;
}
/* readonly attribute nsIDOMElement detail; */
NS_IMETHODIMP nsSOAPFault::GetDetail(nsIDOMElement * *aDetail)
{
NS_ENSURE_ARG_POINTER(aDetail);
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultDetailTagName, aDetail);
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPFault::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPFault::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPFault::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPFault::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPFault_h__
#define nsSOAPFault_h__
#include "nsString.h"
#include "nsISOAPFault.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPFault : public nsISOAPFault,
public nsISecurityCheckedComponent
{
public:
nsSOAPFault(nsIDOMElement* aElement);
virtual ~nsSOAPFault();
NS_DECL_ISUPPORTS
// nsISOAPFault
NS_DECL_NSISOAPFAULT
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsCOMPtr<nsIDOMElement> mFaultElement;
};
#endif

View File

@@ -0,0 +1,297 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPHeaderBlock.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPHeaderBlock::nsSOAPHeaderBlock()
{
NS_INIT_ISUPPORTS();
}
nsSOAPHeaderBlock::~nsSOAPHeaderBlock()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPHeaderBlock,
nsISOAPHeaderBlock,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute AString actorURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAWritableString & aActorURI)
{
NS_ENSURE_ARG_POINTER(&aActorURI);
if (mElement) {
return mElement->GetAttributeNS(nsSOAPUtils::kSOAPEnvURI,nsSOAPUtils::kActorAttribute,aActorURI);
}
else {
aActorURI.Assign(mActorURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetActorURI(const nsAReadableString & aActorURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mActorURI.Assign(aActorURI);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mActorURI.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPHeaderBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
NS_STATIC_CAST(nsAString*, &actorURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
rc = SetActorURI(actorURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPHeaderBlock_h__
#define nsSOAPHeaderBlock_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPHeaderBlock.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPHeaderBlock : public nsISOAPHeaderBlock,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPHeaderBlock();
virtual ~nsSOAPHeaderBlock();
NS_DECL_ISUPPORTS
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsString mActorURI;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@@ -0,0 +1,475 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsIServiceManager.h"
#include "nsMemory.h"
#include "nsIComponentManager.h"
#include "nsSOAPUtils.h"
#include "nsSOAPMessage.h"
#include "nsSOAPParameter.h"
#include "nsSOAPHeaderBlock.h"
#include "nsSOAPEncoding.h"
#include "nsIDOMDocument.h"
#include "nsIDOMParser.h"
#include "nsIDOMElement.h"
#include "nsIDOMNamedNodeMap.h"
static NS_DEFINE_CID(kDOMParserCID, NS_DOMPARSER_CID);
/////////////////////////////////////////////
//
//
/////////////////////////////////////////////
nsSOAPMessage::nsSOAPMessage()
{
NS_INIT_ISUPPORTS();
}
nsSOAPMessage::~nsSOAPMessage()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPMessage,
nsISOAPMessage,
nsISecurityCheckedComponent)
/* attribute nsIDOMDocument message; */
NS_IMETHODIMP nsSOAPMessage::GetMessage(nsIDOMDocument * *aMessage)
{
NS_ENSURE_ARG_POINTER(aMessage);
*aMessage = mMessage;
NS_IF_ADDREF(*aMessage);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetMessage(nsIDOMDocument * aMessage)
{
mMessage = aMessage;
return NS_OK;
}
/* readonly attribute nsIDOMElement envelope; */
NS_IMETHODIMP nsSOAPMessage::GetEnvelope(nsIDOMElement * *aEnvelope)
{
NS_ENSURE_ARG_POINTER(aEnvelope);
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString name, namespaceURI;
root->GetLocalName(name);
root->GetNamespaceURI(namespaceURI);
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)
&& namespaceURI.Equals(nsSOAPUtils::kSOAPEnvURI))
{
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return NS_OK;
}
}
}
*aEnvelope = nsnull;
return NS_OK;
}
/* readonly attribute nsIDOMElement header; */
NS_IMETHODIMP nsSOAPMessage::GetHeader(nsIDOMElement * *aHeader)
{
NS_ENSURE_ARG_POINTER(aHeader);
nsCOMPtr<nsIDOMElement> env;
GetEnvelope(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kHeaderTagName,
aHeader);
}
else {
*aHeader = nsnull;
}
return NS_OK;
}
/* readonly attribute nsIDOMElement body; */
NS_IMETHODIMP nsSOAPMessage::GetBody(nsIDOMElement * *aBody)
{
NS_ENSURE_ARG_POINTER(aBody);
nsCOMPtr<nsIDOMElement> env;
GetEnvelope(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kBodyTagName,
aBody);
}
else {
*aBody = nsnull;
}
return NS_OK;
}
/* attribute DOMString actionURI; */
NS_IMETHODIMP nsSOAPMessage::GetActionURI(nsAWritableString & aActionURI)
{
NS_ENSURE_ARG_POINTER(&aActionURI);
aActionURI.Assign(mActionURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetActionURI(const nsAReadableString & aActionURI)
{
mActionURI.Assign(aActionURI);
return NS_OK;
}
/* readonly attribute AString methodName; */
NS_IMETHODIMP nsSOAPMessage::GetMethodName(nsAString & aMethodName)
{
NS_ENSURE_ARG_POINTER(&aMethodName);
nsCOMPtr<nsIDOMElement> body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetLocalName(aMethodName);
return NS_OK;
}
}
aMethodName.SetLength(0);
return NS_OK;
}
/* readonly attribute AString targetObjectURI; */
NS_IMETHODIMP nsSOAPMessage::GetTargetObjectURI(nsAString & aTargetObjectURI)
{
NS_ENSURE_ARG_POINTER(&aTargetObjectURI);
nsCOMPtr<nsIDOMElement> body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetNamespaceURI(aTargetObjectURI);
return NS_OK;
}
}
aTargetObjectURI.SetLength(0);
return NS_OK;
}
NS_NAMED_LITERAL_STRING(kEmptySOAPDocStr, "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body></SOAP-ENV:Body></SOAP-ENV:Envelope>");
/* void encode (in AString aMethodName, in AString aTargetObjectURI, in PRUint32 aHeaderBlockCount, [array, size_is (aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks, in PRUint32 aParameterCount, [array, size_is (aParameterCount)] in nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::Encode(const nsAString & aMethodName, const nsAString & aTargetObjectURI, PRUint32 aHeaderBlockCount, nsISOAPHeaderBlock **aHeaderBlocks, PRUint32 aParameterCount, nsISOAPParameter **aParameters)
{
// Construct the message skeleton
nsresult rv;
nsCOMPtr<nsIDOMNode> ignored;
nsCOMPtr<nsIDOMParser> parser = do_CreateInstance(kDOMParserCID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString docstr;
rv = parser->ParseFromString(kEmptySOAPDocStr.get(), "text/xml",
getter_AddRefs(mMessage));
if (NS_FAILED(rv)) return rv;
// Declare the default encoding if one exists
if (mEncoding) {
nsCOMPtr<nsIDOMElement> envelope;
rv = GetEnvelope(getter_AddRefs(envelope));
if (NS_FAILED(rv)) return rv;
if (envelope) {
nsAutoString enc;
mEncoding->GetStyleURI(enc);
envelope->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
// Encode and add headers, if any were specified
if (aHeaderBlockCount) {
nsCOMPtr<nsIDOMElement> parent;
rv = GetHeader(getter_AddRefs(parent));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
for (PRUint32 i = 0; i < aHeaderBlockCount; i++) {
header = aHeaderBlocks[i];
if (!header) return NS_ERROR_FAILURE;
rv = header->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = parent->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
element = do_QueryInterface(node1);
}
else {
rv = header->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = header->GetActorURI(actorURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
encoding = mEncoding;
}
rv = header->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = header->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, parent, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (!actorURI.IsEmpty()) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix, nsSOAPUtils::kActorAttribute, actorURI);
}
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
}
nsCOMPtr<nsIDOMElement> body;
rv = GetBody(getter_AddRefs(body));
if (NS_FAILED(rv)) return rv;
// Only produce a call element if mMethodName was non-empty
if (!aMethodName.IsEmpty()) {
nsCOMPtr<nsIDOMElement> call;
rv = mMessage->CreateElementNS(aTargetObjectURI, aMethodName, getter_AddRefs(call));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMNode> ignored;
rv = body->AppendChild(call, getter_AddRefs(ignored));
if (NS_FAILED(rv)) return rv;
body = call;
nsAutoString prefix;
rv = nsSOAPUtils::MakeNamespacePrefixFixed(body, aTargetObjectURI, prefix);
if (NS_FAILED(rv)) return rv;
if (!prefix.IsEmpty()) {
rv = body->SetPrefix(prefix);
if (NS_FAILED(rv)) return rv;
}
}
// Encode and add all of the parameters into the body
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPParameter> param;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
for (PRUint32 i = 0; i < aParameterCount; i++) {
param = aParameters[i];
if (!param) return NS_ERROR_FAILURE;
rv = param->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = body->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
element = do_QueryInterface(node1);
}
else {
rv = param->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = param->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = param->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
encoding = mEncoding;
}
rv = param->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = param->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, body, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
return NS_OK;
}
static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
/* void getHeaderBlocks (out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks); */
NS_IMETHODIMP nsSOAPMessage::GetHeaderBlocks(PRUint32 *aCount, nsISOAPHeaderBlock ***aHeaderBlocks)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
*aCount = 0;
*aHeaderBlocks = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, length * sizeof(**aHeaderBlocks));
}
element = next;
header = new nsSOAPHeaderBlock();
if (NS_FAILED(rv)) return rv;
// XXX can't addref a COMPTr
//NS_ADDREF(header);
(*aHeaderBlocks)[(*aCount)++] = header;
rv = header->SetElement(element);
if (NS_FAILED(rv)) return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, (*aCount) * sizeof(**aHeaderBlocks));
}
return NS_OK;
}
/* void getParameters (in boolean aDocumentStyle, out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::GetParameters(PRBool aDocumentStyle, PRUint32 *aCount, nsISOAPParameter ***aParameters)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
*aCount = 0;
*aParameters = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPParameter> param;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, length * sizeof(**aParameters));
}
element = next;
param = new nsSOAPParameter();
if (NS_FAILED(rv)) return rv;
// XXX can't addref a COMPTr
//NS_ADDREF(param);
(*aParameters)[(*aCount)++] = param;
rv = param->SetElement(element);
if (NS_FAILED(rv)) return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, (*aCount) * sizeof(**aParameters));
}
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPMessage::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
if (!mEncoding) {
mEncoding = new nsSOAPEncoding();
if (!mEncoding)
return NS_ERROR_OUT_OF_MEMORY;
}
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
return NS_OK;
}
static const char*kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPMessage::CanCreateWrapper(const nsIID * iid, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPMessage::CanCallMethod(const nsIID * iid, const PRUnichar*methodName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPMessage::CanGetProperty(const nsIID * iid, const PRUnichar*propertyName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPMessage::CanSetProperty(const nsIID * iid, const PRUnichar*propertyName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPMessage_h__
#define nsSOAPMessage_h__
#include "nsString.h"
#include "nsISOAPEncoding.h"
#include "nsISOAPMessage.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsISupportsArray.h"
#include "nsCOMPtr.h"
#include "nsIVariant.h"
class nsSOAPMessage : public nsISOAPMessage,
public nsISecurityCheckedComponent
{
public:
nsSOAPMessage();
virtual ~nsSOAPMessage();
NS_DECL_ISUPPORTS
// nsISOAPMessage
NS_DECL_NSISOAPMESSAGE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsCOMPtr<nsIDOMDocument> mMessage;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsString mActionURI;
};
#endif

View File

@@ -0,0 +1,271 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPParameter.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPParameter::nsSOAPParameter()
{
NS_INIT_ISUPPORTS();
}
nsSOAPParameter::~nsSOAPParameter()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPParameter,
nsISOAPParameter,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPParameter::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPParameter::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPParameter::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPParameter::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPParameter::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPParameter::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPParameter::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPParameter::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPParameter::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPParameter::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPParameter::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPParameter::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPParameter_h__
#define nsSOAPParameter_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPParameter.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPParameter : public nsISOAPParameter,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPParameter();
virtual ~nsSOAPParameter();
NS_DECL_ISUPPORTS
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@@ -0,0 +1,122 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPResponse.h"
#include "nsSOAPUtils.h"
#include "nsSOAPFault.h"
#include "nsISOAPParameter.h"
nsSOAPResponse::nsSOAPResponse()
{
}
nsSOAPResponse::~nsSOAPResponse()
{
/* destructor code */
}
NS_IMPL_ISUPPORTS_INHERITED1(nsSOAPResponse, nsSOAPMessage, nsISOAPResponse)
/* attribute nsISOAPCall respondingTo; */
NS_IMETHODIMP nsSOAPResponse::GetRespondingTo(nsISOAPCall * *aRespondingTo)
{
NS_ENSURE_ARG_POINTER(aRespondingTo);
*aRespondingTo = mRespondingTo;
NS_IF_ADDREF(*aRespondingTo);
return NS_OK;
}
NS_IMETHODIMP nsSOAPResponse::SetRespondingTo(nsISOAPCall * aRespondingTo)
{
mRespondingTo = aRespondingTo;
return NS_OK;
}
/* readonly attribute nsISOAPFault fault; */
NS_IMETHODIMP nsSOAPResponse::GetFault(nsISOAPFault * *aFault)
{
NS_ENSURE_ARG_POINTER(aFault);
nsCOMPtr<nsIDOMElement> body;
*aFault = nsnull;
GetBody(getter_AddRefs(body));
if (body) {
nsSOAPUtils::GetSpecificChildElement(body,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kFaultTagName,
getter_AddRefs(body));
if (body) {
*aFault = new nsSOAPFault(body);
if (!*aFault)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aFault);
}
}
else {
*aFault = nsnull;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPResponse::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPResponse::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPResponse::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPResponse::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPResponse_h__
#define nsSOAPResponse_h__
#include "nsString.h"
#include "nsSOAPCall.h"
#include "nsISOAPResponse.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPResponse : public nsSOAPMessage,
public nsISOAPResponse
{
public:
NS_DECL_ISUPPORTS
// nsISOAPResponse
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPResponse
NS_DECL_NSISOAPRESPONSE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsSOAPResponse();
virtual ~nsSOAPResponse();
protected:
nsCOMPtr<nsISOAPCall> mRespondingTo;
};
#endif

View File

@@ -0,0 +1,426 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPUtils.h"
#include "nsIDOMText.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsCOMPtr.h"
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEnvURI,"http://schemas.xmlsoap.org/soap/envelope/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEncodingURI,"http://schemas.xmlsoap.org/soap/encoding/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEnvPrefix,"SOAP-ENV");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEncodingPrefix,"SOAP-ENC");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSIURI,"http://www.w3.org/1999/XMLSchema-instance");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSDURI,"http://www.w3.org/1999/XMLSchema");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSIPrefix,"xsi");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSITypeAttribute,"type");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSDPrefix,"xsd");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEncodingStyleAttribute,"encodingStyle");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kActorAttribute,"actor");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEnvelopeTagName,"Envelope");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kHeaderTagName,"Header");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kBodyTagName,"Body");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultTagName,"Fault");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultCodeTagName,"faultcode");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultStringTagName,"faultstring");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultActorTagName,"faultactor");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultDetailTagName,"detail");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEncodingSeparator,"#");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kQualifiedSeparator,":");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceNamespaceURI, "htp://www.w3.org/2000/xmlns/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceURI, "htp://www.w3.org/XML/1998/namespace");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLPrefix, "xml:");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespacePrefix, "xmlns:");
void
nsSOAPUtils::GetSpecificChildElement(
nsIDOMElement *aParent,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
*aElement = nsnull;
GetFirstChildElement(aParent, getter_AddRefs(sibling));
if (sibling)
{
GetSpecificSiblingElement(sibling,
aNamespace, aType, aElement);
}
}
void
nsSOAPUtils::GetSpecificSiblingElement(
nsIDOMElement *aSibling,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
*aElement = nsnull;
sibling = aSibling;
do {
nsAutoString name, namespaceURI;
sibling->GetLocalName(name);
sibling->GetNamespaceURI(namespaceURI);
if (name.Equals(aType)
&& namespaceURI.Equals(nsSOAPUtils::kSOAPEnvURI))
{
*aElement = sibling;
NS_ADDREF(*aElement);
return;
}
nsCOMPtr<nsIDOMElement> temp = sibling;
GetNextSiblingElement(temp, getter_AddRefs(sibling));
} while (sibling);
}
void
nsSOAPUtils::GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement)
{
nsCOMPtr<nsIDOMNode> child;
*aElement = nsnull;
aParent->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
child->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
}
void
nsSOAPUtils::GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement)
{
nsCOMPtr<nsIDOMNode> sibling;
*aElement = nsnull;
GetNextSibling(aStart, getter_AddRefs(sibling));
while (sibling) {
PRUint16 type;
sibling->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
sibling->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = sibling;
GetNextSibling(temp, getter_AddRefs(sibling));
}
}
nsresult
nsSOAPUtils::GetElementTextContent(nsIDOMElement* aElement,
nsAWritableString& aText)
{
nsCOMPtr<nsIDOMNode> child;
nsAutoString rtext;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::TEXT_NODE == type
|| nsIDOMNode::CDATA_SECTION_NODE == type) {
nsCOMPtr<nsIDOMText> text = do_QueryInterface(child);
nsAutoString data;
text->GetData(data);
rtext.Append(data);
}
else if (nsIDOMNode::ELEMENT_NODE == type) {
return NS_ERROR_ILLEGAL_VALUE; // This was interpreted as a simple value, yet had complex content in it.
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
aText.Assign(rtext);
return NS_OK;
}
PRBool
nsSOAPUtils::HasChildElements(nsIDOMElement* aElement)
{
nsCOMPtr<nsIDOMNode> child;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
return PR_TRUE;
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
return PR_FALSE;
}
void
nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
{
nsCOMPtr<nsIDOMNode> last;
nsCOMPtr<nsIDOMNode> current;
PRUint16 type;
*aNext = nsnull;
last = aSibling;
last->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last->GetFirstChild(getter_AddRefs(current));
if (!last)
{
last->GetNextSibling(getter_AddRefs(current));
}
}
else {
last->GetNextSibling(getter_AddRefs(current));
}
while (!current)
{
last->GetParentNode(getter_AddRefs(current));
current->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last = current;
last->GetNextSibling(getter_AddRefs(current));
}
else {
current = nsnull;
break;
}
}
*aNext = current;
NS_IF_ADDREF(*aNext);
}
nsresult nsSOAPUtils::GetNamespaceURI(nsIDOMElement* aScope,
const nsAReadableString & aQName,
nsAWritableString & aURI)
{
aURI.Truncate(0);
PRInt32 i = aQName.FindChar(':');
if (i < 0) {
return NS_OK;
}
nsAutoString prefix;
aQName.Left(prefix, i);
if (prefix.Equals(kXMLPrefix)) {
aURI.Assign(kXMLNamespaceURI);
return NS_OK;
}
nsresult rc;
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString value;
while (current != nsnull) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (attrs) {
rc = attrs->GetNamedItemNS(kXMLNamespaceNamespaceURI, prefix, getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
if (temp != nsnull)
return temp->GetNodeValue(aURI);
}
rc = current->GetParentNode(getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
current = temp;
}
return NS_ERROR_FAILURE;
}
nsresult nsSOAPUtils::GetLocalName(const nsAReadableString & aQName,
nsAWritableString & aLocalName)
{
PRInt32 i = aQName.FindChar(':');
if (i < 0)
aLocalName = aQName;
else
aQName.Mid(aLocalName, i, aQName.Length() - i);
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
const nsAReadableString & aURI,
nsAWritableString & aPrefix)
{
// This may change for level 3 serialization, so be sure to gut this
// and call the standardized level 3 method when it is available.
aPrefix.Truncate(0);
if (aURI.IsEmpty())
return NS_OK;
if (aURI.Equals(nsSOAPUtils::kXMLNamespaceURI)) {
aPrefix.Assign(nsSOAPUtils::kXMLPrefix);
return NS_OK;
}
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString tstr;
nsresult rc;
PRUint32 maxns = 0; // Keep track of max generated NS
for (;;) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (attrs) {
PRUint32 i = 0;
for (;;)
{
attrs->Item(i++, getter_AddRefs(temp));
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(nsSOAPUtils::kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(aURI)) {
nsAutoString prefix;
rc = temp->GetLocalName(prefix);
if (NS_FAILED(rc)) return rc;
nsCOMPtr<nsIDOMNode> check = aScope;
PRBool hasDecl;
nsCOMPtr<nsIDOMElement> echeck;
while (check != current) { // Make sure prefix is not overridden
echeck = do_QueryInterface(check);
if (echeck) {
rc = echeck->HasAttributeNS(nsSOAPUtils::kXMLNamespaceNamespaceURI, prefix, &hasDecl);
if (NS_FAILED(rc)) return rc;
if (hasDecl)
break;
current->GetParentNode(getter_AddRefs(temp));
current = temp;
}
}
if (check == current) {
aPrefix.Assign(prefix);
return NS_OK;
}
}
rc = temp->GetLocalName(tstr);
if (NS_FAILED(rc))
return rc;
else { // Decode the generated namespace into a number
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
tstr.BeginReading(i1);
tstr.EndReading(i2);
if (i1 == i2 || *i1 != 'n')
continue;
i1++;
if (i1 == i2 || *i1 != 's')
continue;
i1++;
PRUint32 n = 0;
while (i1 != i2) {
PRUnichar c = *i1;
i1++;
if (c < '0' || c > '9') {
n = 0;
break;
}
n = n * 10 + (c - '0');
}
if (n > maxns)
maxns = n;
}
}
}
current->GetParentNode(getter_AddRefs(temp));
if (temp)
current = temp;
else
break;
}
// Create a unique prefix...
PRUint32 len = 3;
PRUint32 c = maxns + 1;
while (c >= 10) {
c = c / 10;
len++;
}
// Set the length and write it backwards since that's the easiest way..
aPrefix.SetLength(len);
nsWritingIterator<PRUnichar> i2;
aPrefix.EndWriting(i2);
c = maxns + 1;
while (c > 0) {
PRUint32 r = c % 10;
c = c / 10;
i2--;
*i2 = (PRUnichar)(r + '0');
}
i2--;
*i2 = 's';
i2--;
*i2 = 'n';
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefixFixed(nsIDOMElement* aScope,
const nsAReadableString & aURI,
nsAWritableString & aPrefix)
{
if (aURI.Equals(kSOAPEncodingURI))
aPrefix = kSOAPEncodingPrefix;
else if (aURI.Equals(kSOAPEnvURI))
aPrefix = kSOAPEnvPrefix;
else if (aURI.Equals(kXSIURI))
aPrefix = kXSIPrefix;
else if (aURI.Equals(kXSDURI))
aPrefix = kXSDPrefix;
else
return MakeNamespacePrefix(aScope, aURI, aPrefix);
return NS_OK;
}
PRBool nsSOAPUtils::StartsWith(nsAReadableString& aSuper,
nsAReadableString& aSub)
{
PRUint32 c1 = aSuper.Length();
PRUint32 c2 = aSub.Length();
if (c1 < c2) return PR_FALSE;
if (c1 == c2) return aSuper.Equals(aSub);
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
aSuper.BeginReading(i1);
aSub.BeginReading(i2);
while (c2--) {
if (*i1 != *i2) return PR_FALSE;
i1++;
i2++;
}
return PR_TRUE;
}

View File

@@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPUtils_h__
#define nsSOAPUtils_h__
#include "nsString.h"
#include "nsIDOMElement.h"
class nsSOAPUtils {
public:
static void GetSpecificChildElement(nsIDOMElement *aParent,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement);
static void GetSpecificSiblingElement(nsIDOMElement *aSibling,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement);
static void GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement);
static void GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement);
static nsresult GetElementTextContent(nsIDOMElement* aElement,
nsAWritableString& aText);
static PRBool HasChildElements(nsIDOMElement* aElement);
static void GetNextSibling(nsIDOMNode* aSibling,
nsIDOMNode **aNext);
static nsresult MakeNamespacePrefix(nsIDOMElement* aElement,
const nsAReadableString & aURI,
nsAWritableString & aPrefix);
static nsresult MakeNamespacePrefixFixed(nsIDOMElement* aElement,
const nsAReadableString & aURI,
nsAWritableString & aPrefix);
static nsresult GetNamespaceURI(nsIDOMElement* aElement,
const nsAReadableString & aQName,
nsAWritableString & aURI);
static nsresult GetLocalName(const nsAReadableString & aQName,
nsAWritableString & aLocalName);
// All those missing string functions have to come from somewhere...
static PRBool StartsWith(nsAReadableString& aSuper,
nsAReadableString& aSub);
static nsDependentString kSOAPEnvURI;
static nsDependentString kSOAPEncodingURI;
static nsDependentString kSOAPEnvPrefix;
static nsDependentString kSOAPEncodingPrefix;
static nsDependentString kXSIURI;
static nsDependentString kXSDURI;
static nsDependentString kXSIPrefix;
static nsDependentString kXSITypeAttribute;
static nsDependentString kXSDPrefix;
static nsDependentString kEncodingStyleAttribute;
static nsDependentString kActorAttribute;
static nsDependentString kEnvelopeTagName;
static nsDependentString kHeaderTagName;
static nsDependentString kBodyTagName;
static nsDependentString kFaultTagName;
static nsDependentString kFaultCodeTagName;
static nsDependentString kFaultStringTagName;
static nsDependentString kFaultActorTagName;
static nsDependentString kFaultDetailTagName;
static nsDependentString kEncodingSeparator;
static nsDependentString kQualifiedSeparator;
static nsDependentString kXMLNamespaceNamespaceURI;
static nsDependentString kXMLNamespaceURI;
static nsDependentString kXMLNamespacePrefix;
static nsDependentString kXMLPrefix;
};
// Used to support null strings.
inline PRBool AStringIsNull(const nsAReadableString& aString)
{
return aString.IsVoid() || aString.IsEmpty(); // Get rid of empty hack when string implementations support.
}
inline void SetAStringToNull(nsAWritableString& aString)
{
aString.Truncate();
aString.SetIsVoid(PR_TRUE);
}
#define NS_SOAP_ENSURE_ARG_STRING(arg) \
NS_ENSURE_FALSE(AStringIsNull(arg), NS_ERROR_INVALID_ARG)
#endif

View File

@@ -0,0 +1,31 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,26 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
DIRS=public src
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,19 @@
#
# This is a list of local files which get copied to the mozilla:dist:idl directory
#
nsISOAPAttachments.idl
nsISOAPCall.idl
nsISOAPDecoder.idl
nsISOAPEncoder.idl
nsISOAPEncoding.idl
nsISOAPFault.idl
nsISOAPHeaderBlock.idl
nsISOAPMessage.idl
nsISOAPParameter.idl
nsISOAPResponse.idl
nsISOAPResponseListener.idl
nsISOAPService.idl
nsISOAPServiceRegistry.idl
nsISOAPTransport.idl
nsISOAPTransportListener.idl

View File

@@ -0,0 +1,50 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xmlextras
XPIDL_MODULE = xmlsoap
XPIDLSRCS = \
nsISOAPAttachments.idl \
nsISOAPCall.idl \
nsISOAPDecoder.idl \
nsISOAPEncoder.idl \
nsISOAPEncoding.idl \
nsISOAPFault.idl \
nsISOAPHeaderBlock.idl \
nsISOAPMessage.idl \
nsISOAPParameter.idl \
nsISOAPResponse.idl \
nsISOAPResponseListener.idl \
nsISOAPService.idl \
nsISOAPServiceRegistry.idl \
nsISOAPTransport.idl \
nsISOAPTransportListener.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,46 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
MODULE = xmlextras
XPIDL_MODULE = xmlsoap
XPIDLSRCS = \
.\nsISOAPAttachments.idl \
.\nsISOAPCall.idl \
.\nsISOAPDecoder.idl \
.\nsISOAPEncoder.idl \
.\nsISOAPEncoding.idl \
.\nsISOAPFault.idl \
.\nsISOAPHeaderBlock.idl \
.\nsISOAPMessage.idl \
.\nsISOAPParameter.idl \
.\nsISOAPResponse.idl \
.\nsISOAPResponseListener.idl \
.\nsISOAPService.idl \
.\nsISOAPServiceRegistry.idl \
.\nsISOAPTransport.idl \
.\nsISOAPTransportListener.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
/**
* This interface permits attachment of SOAP attachments.
*/
[scriptable, uuid(6192dcbe-1dd2-11b2-81ad-a4597614c4ae)]
interface nsISOAPAttachments : nsISupports {
/**
* Get the attachment associated with a particular identifier.
*
* @param aIdentifier The identifier of the attachment to be accessed.
*
* Appropriate return(s) must be identified.
*/
void getAttachment(in AString aIdentifier);
/**
* Attach an attachment to the message.
*
* Appropriate argument(s) must be identified.
*
* @return The identifier of the attachment, to be referenced in SOAP encoding
*/
AString attach();
};

View File

@@ -0,0 +1,90 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPMessage.idl"
interface nsISOAPResponse;
interface nsISOAPResponseListener;
/**
* This interface is a convenience extension of the basic SOAP message,
* which handles common patterns of calling, such as providing an
* action URI in the HTTP header, locating and invoking the appropriate
* transport based upon the protocol of the transportURI, and
* automatically recieving the result in a new nsISOAPResponse object
* which recieves an XML message.
*/
[scriptable, uuid(a8fefe40-52bc-11d4-9a57-000064657374)]
interface nsISOAPCall : nsISOAPMessage {
/**
* The URI to which the message will be sent, identifying the
* transport and transport-specific information about the
* destination.
* This does not have to match the <code>targetObjectURI</code>.
*/
attribute AString transportURI;
/**
* Synchronously invoke the call. The method returns only when
* we receive a response (or an error occurs). The
* <code>transportURI</code> must have been set, the
* parameter list (even if empty) must have been encoded,
* and the transportURI must use some known protocol. A
* synchronous call assumes that there will be exactly one
* response per call.
*
* If not, an error is returned in the status of the response.
*
* @returns The SOAP response
*/
nsISOAPResponse invoke();
/**
* Asynchronously invoke the call. At this point, the document
* rooted by the Envelope element is encoded to form the body
* of the SOAP message. The method returns immediately, and the
* listener is invoked when we eventually receive a response
* (or error or successful completion). The
* <code>transportURI</code> must have been set, the
* parameter list (even if empty) must have been encoded,
* and the transportURI must use some known protocol.
*
* If not, an error is returned in the status of the response.
*
* @param aListener Handler to be invoked asynchronously after the
* response is recieved. Should be null if no response is
* expected.
*/
void asyncInvoke(in nsISOAPResponseListener aListener);
};
%{ C++
#define NS_SOAPCALL_CID \
{ /* 87d21ec0-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec0, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPCALL_CONTRACTID \
"@mozilla.org/xmlextras/soap/call;1"
%}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsISOAPEncoding;
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPAttachments;
/**
* This interface supplies decoding of a specific
* part of a message XML DOM into appropriate objects
* for the script or application.
*/
[scriptable, uuid(4c2e02ae-1dd2-11b2-b1cd-c79dea3d46db)]
interface nsISOAPDecoder : nsISupports {
/**
* Decode the source DOM node
*
* @param aEncodings The encodings used to decode
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The DOM node to be decoded.
*
* @param aSchemaType The schema type of the source DOM node
*
* @param aAttachments Dispenses any attachments.
*
* @return The decoded variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsISOAPEncoding aEncoding,
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsISOAPEncoding;
interface nsIVariant;
interface nsIDOMElement;
interface nsISOAPAttachments;
/**
* This interface permits encoding of variants.
*/
[scriptable, uuid(fc33ffd6-1dd1-11b2-8750-fa62430a38b4)]
interface nsISOAPEncoder : nsISupports {
/**
* Encode the source variant.
*
* @param aEncodings The encodings to be used.
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The variant to be encoded.
*
* @param aNamespaceURI The namespace of the thing being coded
*
* @param aName The name of the thing being coded
*
* @param aSchemaType The schema type of the thing being encoded
*
* @param aDestination The node scope, if any, where the result
* will live. If this is null, then the result must be
* explicitly attached to the message.
*
* @return element which was inserted.
*
* @param aAttachments Accumulates any attachments.
*/
nsIDOMElement encode(
in nsISOAPEncoding aEncoding,
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
};

View File

@@ -0,0 +1,184 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsIDOMElement;
interface nsISOAPEncoder;
interface nsISOAPDecoder;
interface nsISOAPMessage;
interface nsIVariant;
interface nsISOAPAttachments;
interface nsISchemaCollection;
/**
* This interface keeps track of all the known types and how
* each should be encoded (by type) or decoded (by
* schema type)
*/
[scriptable, uuid(9ae49600-1dd1-11b2-877f-e62f620c5e92)]
interface nsISOAPEncoding : nsISupports {
/**
* The name of the encoding as it is known to SOAP.
*/
readonly attribute AString styleURI;
/**
* Get an alternative encoding.
*
* @param aStyleURI The style URI of the alternative encoding style.
*
* @param aCreateIf If true, then create the alternative style if it
* does not already exist, otherwise return the existing encoding.
*
* @return The alternative encoding which corresponds to the
* specified styleURI, or null if the spefied alternative encoding
* does not exist and it was not requested that it be created.
*/
nsISOAPEncoding getStyle(
in AString aStyleURI,
in boolean aCreateIf);
/**
* Set an encoder in the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @param aEncoder The encoder to be specified or null to eliminate
* the encoder.
*
* @return Old encoder registered under that type in the encoding, which
* should be kept by the new encoder if it is to be called back.
*/
void setEncoder(in AString aSchemaNamespaceURI, in AString aSchemaType,
in nsISOAPEncoder aEncoder);
/**
* Get an encoder from the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @return The encoder.
*/
nsISOAPEncoder getEncoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
/**
* Set a decoder in the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @param aDecoder The decoder to be specified or null to eliminate
* the decoder.
*
* @return Old decoder registered under that type in the encoding, which
* should be kept by the new decoder if it is to be called back.
*/
void setDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType,
in nsISOAPDecoder aDecoder);
/**
* Get a decoder from the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @return The decoder.
*/
nsISOAPDecoder getDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
attribute nsISOAPEncoder defaultEncoder;
attribute nsISOAPDecoder defaultDecoder;
attribute nsISchemaCollection schemaCollection;
/**
* Encode the source variant
*
* @param aEncodings The encodings to be used.
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The variant to be encoded, soon to become a variant
*
* @param aNamespaceURI The namespace of the thing being coded
*
* @param aName The name of the thing being coded
*
* @param aSchemaType The schema type of the thing being encoded
*
* @param aDestination The node scope where the result will live.
*
* @param aAttachments Accumulates any attachments.
*
* @return The element which was inserted and encoded.
*/
nsIDOMElement encode(
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
/**
* Decode the source DOM node
*
* @param aEncodings The encodings used to decode
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The DOM node to be decoded.
*
* @param aSchemaType The schema type of the source DOM node
*
* @param aAttachments Dispenses any attachments.
*
* @return The decoded variant, soon to become a variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};
%{ C++
#define NS_DEFAULTSOAPENCODER_CID \
{ /* 06fb035c-1dd2-11b2-bc30-f6d8e314d6b9 */ \
0x06fb035c, 0x1dd2, 0x11b2, \
{0xbc, 0x30, 0xf6, 0xd8, 0xe3, 0x14, 0xd6, 0xb9} }
#define NS_SOAPENCODING_CONTRACTID_PREFIX \
"@mozilla.org/xmlextras/soap/encoding;1?uri="
#define NS_DEFAULTSOAPENCODER_CONTRACTID \
NS_SOAPENCODING_CONTRACTID_PREFIX "http://schemas.xmlsoap.org/soap/encoding/"
%}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
/**
* This interface conveniently interprets information about a fault
* that has been returned in a response message.
*
*/
[scriptable, uuid(99ec6694-535f-11d4-9a58-000064657374)]
interface nsISOAPFault : nsISupports {
/**
* The DOM element representing the fault in the response SOAP message.
* This must be set for the rest of the interface to function correctly.
*/
attribute nsIDOMElement element;
/**
* The fault code
*/
readonly attribute AString faultCode;
/**
* The fault string
*/
readonly attribute AString faultString;
/**
* The fault actor if one was specified.
*/
readonly attribute AString faultActor;
/**
* The DOM element representing the fault details
*/
readonly attribute nsIDOMElement detail;
};
%{ C++
#define NS_SOAPFAULT_CID \
{ /* 87d21ec1-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec1, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPFAULT_CONTRACTID \
"@mozilla.org/xmlextras/soap/fault;1"
%}

View File

@@ -0,0 +1,96 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary header block to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
*/
[scriptable, uuid(063d4a4e-1dd2-11b2-a365-cbaf1651f140)]
interface nsISOAPHeaderBlock : nsISupports {
/**
* The namespace URI of the header block. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the header block. If the header block is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The actor URI of the header block.
*/
attribute AString actorURI;
/**
* The encoding that was / will be applied to the
* header block.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* header block.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this header block.
* If this is set, value becomes a computed attribute
* which is produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this header block. If this is set, element becomes null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message.
*/
attribute nsISOAPAttachments attachments;
};
%{ C++
#define NS_SOAPHEADERBLOCK_CID \
{ /* 5ad0eace-1dd2-11b2-a260-ff42edcaedb3 */ \
0x5ad0eace, 0x1dd2, 0x11b2, \
{0xa2, 0x60, 0xff, 0x42, 0xed, 0xca, 0xed, 0xb3} }
#define NS_SOAPHEADERBLOCK_CONTRACTID \
"@mozilla.org/xmlextras/soap/headerblock;1"
%}

View File

@@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsIDOMElement;
interface nsISOAPEncoding;
interface nsISOAPHeaderBlock;
interface nsISOAPParameter;
interface nsIVariant;
/**
* This interface controls all SOAP messages. It permits easy
* construction of a message, typically through encoding of
* parameters and certain properties settable on this interface
* or through deserialization of a transport stream. It
* permits easy processing of a message typically through
* decoding of parameters and certain properties available
* on this interface. It also encapsulates protocol information
* interpreted by the transport.
*/
[scriptable, uuid(3970815e-1dd2-11b2-a475-db4dac6826f1)]
interface nsISOAPMessage : nsISupports {
/**
* The document which captures the message, if any. A simple
* sending application passes parameters to the method
* encodeSOAPParameters, which calls SOAP encoders
* to construct this document along with all contained elements.
*
* But an application may create and set the message directly
* instead of invoking encodeSOAPParameters to use encoders
* or access and manipulate the message after it has been
* constructed by encodeSOAPParameters. If the message has
* not been set, invoking a call will fail. A message reciever
* may also use this accessor to get the document to avoid using
* decoders.
*/
attribute nsIDOMDocument message;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP envelope from the document. DOM methods may be used to
* access, add, or modify attributes of the envelope.
*
* If the message attribute is null or is not a document containing
* a root soap envelope element, then this will be null.
*/
readonly attribute nsIDOMElement envelope;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP header from the envelope. DOM methods may be used to
* access, add, or modify attributes or elements of the header.
*
* If the envelope attribute is null or does not contain a SOAP header
* element type, then this will be null.
*/
readonly attribute nsIDOMElement header;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP body from the envelope. DOM methods may be used to
* access, add, or modify attributes or elements of the body.
*
* If the envelope attribute is null or does not contain a SOAP body
* element type, then this will be null.
*/
readonly attribute nsIDOMElement body;
/**
* The name of the method being invoked. The methodName is set
* during encoding as the tagname of the single child of body
* of RPC-style messages. When there is no encoded message
* this will be null. The value of this attribute for
* document-style messages may be non-null but should be
* ignored. It is up to the application to know whether the
* message is RPC-style or document style because the SOAP
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString methodName;
/**
* The target object on which the method is being invoked. This URI
* is set during encoding as the namespace to qualify the tagname
* of the single child of body of RPC-style messages. When there
* is no encoded message, this will be null. The value of this
* attribute for document-style messages may be non-null but should
* be ignored. It is up to the application to know whether the
* message is RPC-style or document style because the SOAP
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString targetObjectURI;
/**
* Encodes the specified parameters into this message, if
* this message type supports it.
*
* @param aMethodName The name of the method being invoked
* for rpc-style messages. For document-style messages,
* this must be null.
*
* @param aTargetObjectURI The name of the target object
* for rpc-style messages. For document-style messages,
* this must be null.
*
* @param aHeaderBlockCount Number of header blocks in array to be
* encoded. Must be 0 if header block array is null.
*
* @param aHeaderBlocks Array of header blocks to be encoded, which
* may be null if there are no header blocks.
*
* @param aParameterCount Number of parameters in array
* to be encoded. Must be 0 if parameter array is null.
*
* @param aParameters An array of parameters to be
* encoded, which may null if there are no parameters.
*/
void encode(
in AString aMethodName, in AString aTargetObjectURI,
in PRUint32 aHeaderBlockCount,
[array, size_is(aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks,
in PRUint32 aParameterCount,
[array, size_is(aParameterCount)] in nsISOAPParameter aParameters);
/**
* Gathers the header blocks of a message so that they can be
* accessed by a recipient.
*
* @param aCount Integer to receive the length of the list
* of header blocks.
*
* @return Array of header blocks found in the message.
*/
void getHeaderBlocks(out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks);
/**
* Gathers the parameters of a message so that they can be
* accessed by a recipient.
*
* @param aDocumentStyle If true, then the parameters
* are looked for treating the message as a document
* style message, otherwise it treated as an RPC-style
* message.
*
* @param aCount Integer to receive the length of the list
* of parameters.
*
* @return Array of parameters found in the message.
*/
void getParameters(in boolean aDocumentStyle,
out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPParameter aParameters);
/**
* The primary encoding of the message, which is established
* at the envelope and used unless overridden. By default,
* this is the SOAP encoding, which may be locally modified
* or used to obtain alternative encodings, which may be
* locally modified, but it may be set to an encoding that
* is shared, or it may be set to null, in which case all
* non-literal header blocks and parameters must specify an
* encoding.
*/
attribute nsISOAPEncoding encoding;
/**
* An optional URI that can be used to add a SOAPAction HTTP
* header field. If this attribute is NULL (the default case),
* no SOAPAction header will be added.
*/
attribute AString actionURI;
};

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary parameter to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
*/
[scriptable, uuid(99ec6690-535f-11d4-9a58-000064657374)]
interface nsISOAPParameter : nsISupports {
/**
* The namespace URI of the parameter. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the parameter. If the parameter is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The encoding that was / will be applied to the
* parameter.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* parameter.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this parameter.
* If this is set, value becomes a computed attribute
* which may be produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this parameter. If this is set, element becomes
* null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message
* that may be needed to decode the parameter.
*/
attribute nsISOAPAttachments attachments;
};
%{ C++
#define NS_SOAPPARAMETER_CID \
{ /* 87d21ec2-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec2, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPPARAMETER_CONTRACTID \
"@mozilla.org/xmlextras/soap/parameter;1"
%}

View File

@@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPCall.idl"
interface nsISOAPParameter;
interface nsISOAPFault;
/**
* This is an extension of a message which contains extra functions
* such as tracking, where appropriate, the original call that
* produced the response message, identifying the fault, if any,
* and supplying the return value.
*/
[scriptable, uuid(99ec6691-535f-11d4-9a58-000064657374)]
interface nsISOAPResponse : nsISOAPMessage {
/**
* The message which generated this response. There is no guarantee
* that the message has not been modified since the original call
* occurred. This is set automatically when invoking a call that
* returns this response. This must also be set by a call processor
* so that the transport can return a response to the correct caller.
*/
attribute nsISOAPCall respondingTo;
/**
* The fault returned in the response, if one was generated. NULL
* if there was no fault. This does not rely on the response
* parameters having been deserialized.
*/
readonly attribute nsISOAPFault fault;
};
%{ C++
#define NS_SOAPRESPONSE_CID \
{ /* 87d21ec3-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec3, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPRESPONSE_CONTRACTID \
"@mozilla.org/xmlextras/soap/response;1"
%}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPCall;
interface nsISOAPResponse;
/**
* This interface represents a response handler to be invoked whenever
* a response of a particular call is recieved and when no more
* responses are expected.
*/
[scriptable, uuid(99ec6692-535f-11d4-9a58-000064657374)]
interface nsISOAPResponseListener : nsISupports {
/**
* This method is invoked when we receive an asynchronous response to
* a SOAP message. The listener is registered as part of the original
* asynchronous call invocation.
*
* @param aResponse The decoded version of the response. If an
* error occurred transmitting the response, the status field
* of the response will contain an error code. The last call
* to the listener may contain a null response, which should
* only be interpreted as an error if your call expected more
* results than it got. If the service or the transport
* do not know whether to expect more results, then setting
* the last parameter true may only be possible after the
* last response has already been delivered.
*
* @param aLast True if this is the last call to the listener.
*
* @return True to make this the last call to the listener, even
* if last was not true. Calls which expect a single response
* should return true upon receiving that response to avoid
* possibly recieving another callback with a null response
* indicating that the last response was already sent.
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in unsigned long status, in boolean aLast);
};

View File

@@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPMessage;
interface nsISOAPResponseListener;
/**
* This interface describes a service which may be
* applied to incoming messages. The service is
* responsible for determining whether the message
* is one that it should process and rejecting it
* if it is not. Services may be chained.
*/
[scriptable, uuid(9927fa40-1dd1-11b2-a8d1-857ad21b872c)]
interface nsISOAPService : nsISupports {
/**
* Configuration object that may contain more info on the service
*/
attribute nsISupports configuration;
/**
* Process an incoming message.
*
* @param aMessage message to be processed
*
* @param aListener listener to which to report results
*
* @return True if the message will be handled, false if
* it should be given to some other service or fail.
* In case of failure, a more detailed status will be
* recorded in the message.
*/
boolean process(in nsISOAPMessage aMessage,
in nsISOAPResponseListener aListener);
};
%{ C++
#define NS_SOAPJSSERVICE_CID \
{ /* 26a41df2-1dd2-11b2-9f29-909e637afa0e */ \
0x26a41df2, 0x1dd2, 0x11b2, \
{0x9f, 0x29, 0x90, 0x9e, 0x63, 0x7a, 0xfa, 0x0e} }
#define NS_SOAPJSSERVICE_CONTRACTID \
"@mozilla.org/xmlextras/soap/jsservice;1"
%}

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsISOAPService;
interface nsISOAPEncodingRegistry;
/**
* This interface represents a registry of SOAP services.
* This registry recieves transports to listen for messages
* and services to hand the messages to. Service registries
* may be created as required. Destroying a service registry
* stops the registry's action. To temporarily register
* services, create a new registry. For proper order of
* listening precedence, registries should be destroyed
* in reverse order. Otherwise, a listening priority
* would be required.
*/
[scriptable, uuid(9790d6bc-1dd1-11b2-afe0-bcb310c078bf)]
interface nsISOAPServiceRegistry {
/**
* Process a configuration and add the resulting sources
* and services. This will fail if errors occur during
* processing of the configuration.
*
* @param aConfiguration Root element of configuration XML.
*/
boolean addConfiguration(in nsIDOMElement aConfiguration);
/**
* Add a transport to be serviced by the registered services.
* This will fail if the specified source was already added
* with the same setting of the capture flag.
*
* @param aTransport string specifying the transport to supply
* messages for the service.
*
* @param aCapture True if capturing before later declarations
*/
void addSource(in AString aTransport, in boolean aCapture);
/**
* Add a service to service the registered transports. This
* will fail if the specified service was already added.
*
* @param aService Service to be serviced.
*/
void addService(in nsISOAPService aService);
/**
* Registry identifying how to encode and decode
* messages containing specific types, automatically
* added to messages sent to services in this
* registry.
*/
attribute nsISOAPEncodingRegistry encodings;
};
%{ C++
#define NS_SOAPSERVICEREGISTRY_CID \
{ /* 3869184e-1dd2-11b2-aa36-d8333498043a */ \
0x3869184e, 0x1dd2, 0x11b2, \
{0xaa, 0x36, 0xd8, 0x33, 0x34, 0x98, 0x04, 0x3a} }
#define NS_SOAPSERVICEREGISTRY_CONTRACTID \
"@mozilla.org/xmlextras/soap/serviceregistry;1"
#define NS_SOAPDEFAULTSERVICEREGISTRY_CID \
{ /* 9120a01e-1dd2-11b2-a61f-906766927a4f */ \
0x9120a01e, 0x1dd2, 0x11b2, \
{0xa6, 0x1f, 0x90, 0x67, 0x66, 0x92, 0x7a, 0x4f} }
#define NS_SOAPDEFAULTSERVICEREGISTRY_CONTRACTID \
"@mozilla.org/xmlextras/soap/defaultserviceregistry;1"
%}

View File

@@ -0,0 +1,102 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPTransportListener;
interface nsISOAPCall;
interface nsISOAPResponse;
interface nsISOAPResponseListener;
[scriptable, uuid(99ec6695-535f-11d4-9a58-000064657374)]
interface nsISOAPTransport : nsISupports {
/**
* Send the specified message to the specified destination.
* This will fail if synchronous calls are not supported or if there is any
* failure in the actual message exchange. Failure of the call itself will be
* contained in the response.
*
* @param aCall Actual message to be sent.
*
* @param aResponse Message to be recieved. Calling synchronously assumes that
* exactly one response is expected.
*/
void syncCall( in nsISOAPCall aCall,
in nsISOAPResponse aResponse);
/**
* Send the specified message to the specified destination synchronously waiting
* for completion and any response.
* This will fail if there is any failure in the setup of the message exchange.
* Later errors will only be known through the response listener. Failures of the
* call itself will be contained in the response passed to the response listener.
*
* @param aCall Actual message to be sent.
*
* @param aListener Handler to be invoked (single threaded) as each response is
* received and finally with null. If specified as null, no responses are returned.
*
* @param response Message to recieve response and be handled by listener. May be
* null if listener is null.
*/
void asyncCall(in nsISOAPCall aCall,
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);
/**
* Add listener for unsolicited messages arriving on the transport. Listeners
* are provided with the opportunity to accept and process messages. Typically
* a listener will be a service dispatcher. Listeners will be invoked in the
* reverse order of declaration, allowing more local service dispatchers to
* temporarily override permanent service dispatchers. This will fail if the
* desired listener was already added to the transport with the specified
* capture flag or if the transport does not support incoming messages.
*
* @param aListener The listener to recieve unsolicited messages from the
* transport.
*
* @param aCapture True if the listener should capture the message before
* later-declared services.
*/
void addListener(in nsISOAPTransportListener aListener, in boolean aCapture);
/**
* Remove listener for unsolicited messages arriving on the transport. This
* will fail if the specified listener was not added with the specified
* capture setting.
*
* @param aListener The listener to stop from recieving unsolicited messages
* from the transport.
*
* @param aCapture True if the listener was added to capture the message before
* later-declared services (must be specified to remove, since a listener
* may be registered as both).
*/
void removeListener(in nsISOAPTransportListener aListener, in boolean aCapture);
};
%{ C++
#define NS_SOAPTRANSPORT_CONTRACTID \
"@mozilla.org/xmlextras/soap/transport;1"
#define NS_SOAPTRANSPORT_CONTRACTID_PREFIX NS_SOAPTRANSPORT_CONTRACTID "?protocol="
%}

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsISOAPMessage;
/**
* This interface recieves control when an unsolicited transport
* is recieved on a transport.
*/
[scriptable, uuid(99ec6696-535f-11d4-9a58-000064657374)]
interface nsISOAPTransportListener : nsISupports {
/**
* This method is invoked when an unsolicited message is
* recieved. First all listeners are tried in the order declared
* with the capture flag set. Then all listeners are tried in
* the reverse order declared with the capture flag clear.
*
* @param aMessage Actual message.
*
* @param aCapture True if the listener is being permitted to gain
* control before all later-added listeners.
*
* @return true if message is handled, false if it was not
*/
boolean handleMessage(in nsISOAPMessage aMessage, in boolean aCapture);
};

View File

@@ -0,0 +1,52 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = ../../../..
srcdir = .
VPATH = .
include $(DEPTH)/config/autoconf.mk
MODULE = xmlextras
LIBRARY_NAME = xmlextrassoap_s
REQUIRES = xpcom string caps dom js widget layout xpconnect necko
CPPSRCS = \
nsSOAPCall.cpp \
nsDefaultSOAPEncoder.cpp\
nsSOAPFault.cpp \
nsSOAPHeaderBlock.cpp \
nsSOAPJSValue.cpp \
nsSOAPMessage.cpp \
nsSOAPParameter.cpp \
nsSOAPResponse.cpp \
nsSOAPStruct.cpp \
nsSOAPUtils.cpp \
nsSOAPEncodingRegistry.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,52 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xmlextras
LIBRARY_NAME = xmlextrassoap_s
REQUIRES = xpcom string caps dom js widget xpconnect necko schema
CPPSRCS = \
nsDefaultSOAPEncoder.cpp\
nsHTTPSOAPTransport.cpp \
nsSOAPCall.cpp \
nsSOAPEncoding.cpp \
nsSOAPFault.cpp \
nsSOAPHeaderBlock.cpp \
nsSOAPMessage.cpp \
nsSOAPParameter.cpp \
nsSOAPResponse.cpp \
nsSOAPUtils.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
#override NO_SHARED_LIB=1
#override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,64 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
LIBRARY_NAME=xmlextrassoap_s
MODULE=xmlextras
REQUIRES = \
xpcom \
string \
caps \
dom \
js \
widget \
xpconnect \
necko
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
OBJS= \
.\$(OBJDIR)\nsDefaultSOAPEncoder.obj \
.\$(OBJDIR)\nsHTTPSOAPTransport.obj \
.\$(OBJDIR)\nsSOAPCall.obj \
.\$(OBJDIR)\nsSOAPEncoding.obj \
.\$(OBJDIR)\nsSOAPFault.obj \
.\$(OBJDIR)\nsSOAPHeaderBlock.obj \
.\$(OBJDIR)\nsSOAPMessage.obj \
.\$(OBJDIR)\nsSOAPParameter.obj \
.\$(OBJDIR)\nsSOAPResponse.obj \
# .\$(OBJDIR)\nsSOAPStruct.obj \
.\$(OBJDIR)\nsSOAPUtils.obj \
$(NULL)
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsDefaultSOAPEncoder_h__
#define nsDefaultSOAPEncoder_h__
#include "nsSOAPEncoding.h"
class nsDefaultSOAPEncoder : public nsSOAPEncoding
{
public:
nsDefaultSOAPEncoder();
};
#endif

View File

@@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsHTTPSOAPTransport.h"
#include "nsIComponentManager.h"
#include "nsIDOMDocument.h"
#include "nsString.h"
#include "nsSOAPUtils.h"
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsIDOMEventTarget.h"
nsHTTPSOAPTransport::nsHTTPSOAPTransport()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransport::~nsHTTPSOAPTransport()
{
}
NS_IMPL_ISUPPORTS1_CI(nsHTTPSOAPTransport, nsISOAPTransport)
/* void syncCall (in nsISOAPCall aCall, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse *aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
}
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMDocument> messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_FALSE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
request->GetStatus(&rv);
if (NS_FAILED(rv)) return rv;
if (aResponse) {
nsCOMPtr<nsIDOMDocument> response;
rv = request->GetResponseXML(getter_AddRefs(response));
if (NS_FAILED(rv)) return rv;
rv = aResponse->SetMessage(response);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener
{
public:
nsHTTPSOAPTransportCompletion();
virtual ~nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
protected:
nsCOMPtr<nsISOAPCall> mCall;
nsCOMPtr<nsISOAPResponse> mResponse;
nsCOMPtr<nsIXMLHttpRequest> mRequest;
nsCOMPtr<nsISOAPResponseListener> mListener;
};
NS_IMPL_ISUPPORTS1(nsHTTPSOAPTransportCompletion, nsIDOMEventListener)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransportCompletion::~nsHTTPSOAPTransportCompletion()
{
}
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent* aEvent)
{
nsresult rv;
mRequest->GetStatus(&rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv)) {
rv = mResponse->SetMessage(document);
}
}
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, (PRInt32)rv, PR_TRUE, &c);
return NS_OK;
}
/* void asyncCall (in nsISOAPCall aCall, in nsISOAPResponseListener aListener, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponseListener *aListener, nsISOAPResponse *aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(request, &rv);
if (NS_FAILED(rv)) return rv;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIDOMEventListener> listener = new nsHTTPSOAPTransportCompletion();
if (!listener) return NS_ERROR_OUT_OF_MEMORY;
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMDocument> messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_TRUE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
eventTarget->AddEventListener(NS_LITERAL_STRING("load"), listener, PR_FALSE);
eventTarget->AddEventListener(NS_LITERAL_STRING("error"), listener, PR_FALSE);
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
/* void addListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::AddListener(nsISOAPTransportListener *aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void removeListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::RemoveListener(nsISOAPTransportListener *aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsHTTPSOAPTransport_h__
#define nsHTTPSOAPTransport_h__
#include "nsISOAPTransport.h"
#include "nsIXMLHttpRequest.h"
#include "nsIDOMEventListener.h"
#include "nsISOAPTransportListener.h"
#include "nsCOMPtr.h"
class nsHTTPSOAPTransport : public nsISOAPTransport
{
public:
nsHTTPSOAPTransport();
virtual ~nsHTTPSOAPTransport();
NS_DECL_ISUPPORTS
// nsISOAPTransport
NS_DECL_NSISOAPTRANSPORT
};
#define NS_HTTPSOAPTRANSPORT_CID \
{ /* d852ade0-5823-11d4-9a62-00104bdf5339 */ \
0xd852ade0, 0x5823, 0x11d4, \
{0x9a, 0x62, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_HTTPSOAPTRANSPORT_CONTRACTID NS_SOAPTRANSPORT_CONTRACTID_PREFIX "http"
#endif

View File

@@ -0,0 +1,187 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsSOAPUtils.h"
#include "nsISOAPTransport.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
/////////////////////////////////////////////
//
//
/////////////////////////////////////////////
nsSOAPCall::nsSOAPCall()
{
}
nsSOAPCall::~nsSOAPCall()
{
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPCall, nsISOAPMessage, nsISOAPCall)
NS_IMPL_ADDREF_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPCall)
NS_INTERFACE_MAP_ENTRY(nsISOAPCall)
NS_IMPL_QUERY_CLASSINFO(nsSOAPCall)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* attribute DOMString transportURI; */
NS_IMETHODIMP nsSOAPCall::GetTransportURI(nsAWritableString & aTransportURI)
{
NS_ENSURE_ARG_POINTER(&aTransportURI);
aTransportURI.Assign(mTransportURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPCall::SetTransportURI(const nsAReadableString & aTransportURI)
{
mTransportURI.Assign(aTransportURI);
return NS_OK;
}
nsresult
nsSOAPCall::GetTransport(nsISOAPTransport** aTransport)
{
NS_ENSURE_ARG_POINTER(aTransport);
nsresult rv;
nsCOMPtr<nsIURI> uri;
nsXPIDLCString protocol;
nsCString transportURI(ToNewCString(mTransportURI));
rv = NS_NewURI(getter_AddRefs(uri), transportURI.get());
if (NS_FAILED(rv)) return rv;
uri->GetScheme(getter_Copies(protocol));
nsCAutoString transportContractid;
transportContractid.Assign(NS_SOAPTRANSPORT_CONTRACTID_PREFIX);
transportContractid.Append(protocol);
nsCOMPtr<nsISOAPTransport> transport = do_GetService(transportContractid.get(), &rv);
if (NS_FAILED(rv)) return rv;
*aTransport = transport.get();
NS_ADDREF(*aTransport);
return NS_OK;
}
/* nsISOAPResponse invoke (); */
NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response;
response = new nsSOAPResponse();
if (!response) return NS_ERROR_OUT_OF_MEMORY;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->SyncCall(this, response);
if (NS_FAILED(rv)) return rv;
return response->QueryInterface(NS_GET_IID(nsISOAPResponse), (void**)_retval);
}
/* void asyncInvoke (in nsISOAPResponseListener listener); */
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener)
{
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response;
response = new nsSOAPResponse();
if (!response) return NS_ERROR_OUT_OF_MEMORY;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->AsyncCall(this, listener, response);
return rv;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPCall::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPCall::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPCall::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPCall::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPCall_h__
#define nsSOAPCall_h__
#include "nsString.h"
#include "nsSOAPMessage.h"
#include "nsISOAPCall.h"
#include "nsISecurityCheckedComponent.h"
#include "nsISOAPTransport.h"
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsSOAPCall : public nsSOAPMessage,
public nsISOAPCall
{
public:
nsSOAPCall();
virtual ~nsSOAPCall();
NS_DECL_ISUPPORTS
// nsISOAPCall
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPCall
NS_DECL_NSISOAPCALL
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsString mTransportURI;
nsresult GetTransport(nsISOAPTransport** aTransport);
};
#endif

View File

@@ -0,0 +1,405 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsISOAPParameter.h"
#include "nsSOAPMessage.h"
#include "nsISOAPEncoder.h"
#include "nsISOAPDecoder.h"
#include "nsSOAPEncoding.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIDOMNodeList.h"
#include "nsISchema.h"
#include "nsISchemaLoader.h"
#include "nsSOAPUtils.h"
// First comes the registry which shares between associated encodings but is never seen by xpconnect.
NS_IMPL_ISUPPORTS1(nsSOAPEncodingRegistry,nsISOAPEncoding)
nsSOAPEncodingRegistry::nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding): mEncodings(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
nsAutoString style;
aEncoding->GetStyleURI(style);
nsStringKey styleKey(style);
mEncodings->Put(&styleKey, aEncoding);
/* member initializers and constructor code */
}
nsSOAPEncodingRegistry::~nsSOAPEncodingRegistry()
{
/* destructor code */
delete mEncodings;
}
nsresult nsSOAPEncodingRegistry::GetStyle(const nsAString& aStyleURI, PRBool aCreateIf, nsISOAPEncoding* * aEncoding)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(aEncoding);
nsStringKey styleKey(aStyleURI);
*aEncoding = (nsISOAPEncoding*)mEncodings->Get(&styleKey);
if (!*aEncoding)
{
nsCOMPtr<nsISOAPEncoding> defaultEncoding;
nsCAutoString encodingContractid;
encodingContractid.Assign(NS_SOAPENCODING_CONTRACTID_PREFIX);
encodingContractid.Append(NS_ConvertUCS2toUTF8(aStyleURI));
defaultEncoding = do_GetService(encodingContractid.get());
if (defaultEncoding || aCreateIf) {
*aEncoding = new nsSOAPEncoding(aStyleURI, this, defaultEncoding);
mEncodings->Put(&styleKey, *aEncoding);
}
}
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
mSchemaCollection = aSchemaCollection;
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
if (!mSchemaCollection) {
nsresult rv;
nsCOMPtr<nsISchemaLoader>loader = do_CreateInstance(NS_SCHEMALOADER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
mSchemaCollection = do_QueryInterface(loader);
if (!mSchemaCollection) return NS_ERROR_FAILURE;
}
*aSchemaCollection = mSchemaCollection;
NS_ADDREF(*aSchemaCollection);
return NS_OK;
}
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetStyleURI(nsAString & aStyleURI)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder *aEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder getEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder setDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder *aDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder getDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// Second, we create the encodings themselves.
NS_IMPL_ISUPPORTS2(nsSOAPEncoding, nsISOAPEncoding, nsISecurityCheckedComponent)
nsSOAPEncoding::nsSOAPEncoding(): mEncoders(new nsSupportsHashtable),
mDecoders(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(nsSOAPUtils::kSOAPEncodingURI);
mDefaultEncoding = do_GetService(NS_DEFAULTSOAPENCODER_CONTRACTID);
mRegistry = new nsSOAPEncodingRegistry(this);
}
nsSOAPEncoding::nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry* aRegistry, nsISOAPEncoding* aDefaultEncoding)
: mEncoders(new nsSupportsHashtable), mDecoders(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(aStyleURI);
mRegistry = aRegistry;
mDefaultEncoding = aDefaultEncoding;
}
nsSOAPEncoding::~nsSOAPEncoding()
{
/* destructor code */
delete mEncoders;
delete mDecoders;
}
nsresult nsSOAPEncoding::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
return mRegistry->SetSchemaCollection(aSchemaCollection);
}
nsresult nsSOAPEncoding::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
return mRegistry->GetSchemaCollection(aSchemaCollection);
}
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncoding::GetStyleURI(nsAString & aStyleURI)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
aStyleURI.Assign(mStyleURI);
return NS_OK;
}
/* nsISOAPEncoding getStyle (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetStyle(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(_retval);
return mRegistry->GetStyle(aStyleURI, aCreateIf, _retval);
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncoding::SetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder *aEncoder)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG(aEncoder);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
if (aEncoder) {
mEncoders->Put(&nameKey, aEncoder, nsnull);
}
else {
mEncoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPEncoder getEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncoding::GetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG_POINTER(_retval);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
*_retval = (nsISOAPEncoder*)mEncoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetEncoder(aSchemaNamespaceURI, aSchemaType, _retval);
}
return NS_OK;
}
/* nsISOAPDecoder setDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncoding::SetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder *aDecoder)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
if (aDecoder) {
mDecoders->Put(&nameKey, aDecoder, nsnull);
}
else {
mDecoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPDecoder getDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncoding::GetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG_POINTER(_retval);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
*_retval = (nsISOAPDecoder*)mDecoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetDecoder(aSchemaNamespaceURI, aSchemaType, _retval);
}
return NS_OK;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncoding::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPEncoder> encoder;
nsresult rv = GetDefaultEncoder(getter_AddRefs(encoder));
if (NS_FAILED(rv)) return rv;
if (encoder) {
return encoder->Encode(this, aSource, aNamespaceURI, aName, aSchemaType, aAttachments, aDestination,
_retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncoding::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPDecoder> decoder;
nsresult rv = GetDefaultDecoder(getter_AddRefs(decoder));
if (NS_FAILED(rv)) return rv;
if (decoder) {
return decoder->Decode(this, aSource, aSchemaType, aAttachments, _retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
NS_ENSURE_ARG_POINTER(aDefaultEncoder);
if (mDefaultEncoding && !mDefaultEncoder) {
return mDefaultEncoding->GetDefaultEncoder(aDefaultEncoder);
}
*aDefaultEncoder = mDefaultEncoder;
NS_IF_ADDREF(*aDefaultEncoder);
return NS_OK;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
mDefaultEncoder = aDefaultEncoder;
return NS_OK;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
NS_ENSURE_ARG_POINTER(aDefaultDecoder);
if (mDefaultEncoding && !mDefaultDecoder) {
return mDefaultEncoding->GetDefaultDecoder(aDefaultDecoder);
}
*aDefaultDecoder = mDefaultDecoder;
NS_IF_ADDREF(*aDefaultDecoder);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
mDefaultDecoder = aDefaultDecoder;
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPEncoding::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPEncoding::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPEncoding::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPEncoding::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPEncodingRegistry_h__
#define nsSOAPEncodingRegistry_h__
#include "nsString.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsISOAPEncoding.h"
#include "nsISOAPEncoder.h"
#include "nsISOAPDecoder.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsISchema.h"
class nsSOAPEncoding;
/* Header file */
class nsSOAPEncodingRegistry : public nsISOAPEncoding
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
nsSOAPEncodingRegistry() {}
nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding);
virtual ~nsSOAPEncodingRegistry();
protected:
nsSupportsHashtable* mEncodings;
nsCOMPtr<nsISchemaCollection> mSchemaCollection;
};
class nsSOAPEncoding : public nsISOAPEncoding,
public nsISecurityCheckedComponent
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsSOAPEncoding();
nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry * aRegistry, nsISOAPEncoding* aDefaultEncoding);
virtual ~nsSOAPEncoding();
/* additional members */
protected:
nsString mStyleURI;
nsSupportsHashtable* mEncoders;
nsSupportsHashtable* mDecoders;
nsCOMPtr<nsISOAPEncoding> mRegistry;
nsCOMPtr<nsISOAPEncoding> mDefaultEncoding;
nsCOMPtr<nsISOAPEncoder> mDefaultEncoder;
nsCOMPtr<nsISOAPDecoder> mDefaultDecoder;
};
#endif

View File

@@ -0,0 +1,154 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPFault.h"
#include "nsSOAPUtils.h"
#include "nsIDOMNodeList.h"
nsSOAPFault::nsSOAPFault(nsIDOMElement* aElement)
{
NS_INIT_ISUPPORTS();
mFaultElement = aElement;
}
nsSOAPFault::~nsSOAPFault()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPFault, nsISOAPFault, nsISecurityCheckedComponent)
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPFault::SetElement(nsIDOMElement *aElement)
{
mFaultElement = aElement;
return NS_OK;
}
NS_IMETHODIMP nsSOAPFault::GetElement(nsIDOMElement * *aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mFaultElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
/* readonly attribute wstring faultCode; */
NS_IMETHODIMP nsSOAPFault::GetFaultCode(nsAWritableString & aFaultCode)
{
NS_ENSURE_ARG_POINTER(&aFaultCode);
aFaultCode.Truncate();
nsCOMPtr<nsIDOMElement> faultcode;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultCodeTagName,
getter_AddRefs(faultcode));
if (faultcode) {
nsSOAPUtils::GetElementTextContent(faultcode, aFaultCode);
}
return NS_OK;
}
/* readonly attribute wstring faultString; */
NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAWritableString & aFaultString)
{
NS_ENSURE_ARG_POINTER(&aFaultString);
aFaultString.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultStringTagName, getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultString);
}
return NS_OK;
}
/* readonly attribute wstring faultActor; */
NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAWritableString & aFaultActor)
{
NS_ENSURE_ARG_POINTER(&aFaultActor);
aFaultActor.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultActorTagName, getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultActor);
}
return NS_OK;
}
/* readonly attribute nsIDOMElement detail; */
NS_IMETHODIMP nsSOAPFault::GetDetail(nsIDOMElement * *aDetail)
{
NS_ENSURE_ARG_POINTER(aDetail);
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultDetailTagName, aDetail);
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPFault::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPFault::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPFault::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPFault::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPFault_h__
#define nsSOAPFault_h__
#include "nsString.h"
#include "nsISOAPFault.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPFault : public nsISOAPFault,
public nsISecurityCheckedComponent
{
public:
nsSOAPFault(nsIDOMElement* aElement);
virtual ~nsSOAPFault();
NS_DECL_ISUPPORTS
// nsISOAPFault
NS_DECL_NSISOAPFAULT
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsCOMPtr<nsIDOMElement> mFaultElement;
};
#endif

View File

@@ -0,0 +1,297 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPHeaderBlock.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPHeaderBlock::nsSOAPHeaderBlock()
{
NS_INIT_ISUPPORTS();
}
nsSOAPHeaderBlock::~nsSOAPHeaderBlock()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPHeaderBlock,
nsISOAPHeaderBlock,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute AString actorURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAWritableString & aActorURI)
{
NS_ENSURE_ARG_POINTER(&aActorURI);
if (mElement) {
return mElement->GetAttributeNS(nsSOAPUtils::kSOAPEnvURI,nsSOAPUtils::kActorAttribute,aActorURI);
}
else {
aActorURI.Assign(mActorURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetActorURI(const nsAReadableString & aActorURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mActorURI.Assign(aActorURI);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mActorURI.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPHeaderBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
NS_STATIC_CAST(nsAString*, &actorURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
rc = SetActorURI(actorURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPHeaderBlock_h__
#define nsSOAPHeaderBlock_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPHeaderBlock.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPHeaderBlock : public nsISOAPHeaderBlock,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPHeaderBlock();
virtual ~nsSOAPHeaderBlock();
NS_DECL_ISUPPORTS
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsString mActorURI;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@@ -0,0 +1,475 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsIServiceManager.h"
#include "nsMemory.h"
#include "nsIComponentManager.h"
#include "nsSOAPUtils.h"
#include "nsSOAPMessage.h"
#include "nsSOAPParameter.h"
#include "nsSOAPHeaderBlock.h"
#include "nsSOAPEncoding.h"
#include "nsIDOMDocument.h"
#include "nsIDOMParser.h"
#include "nsIDOMElement.h"
#include "nsIDOMNamedNodeMap.h"
static NS_DEFINE_CID(kDOMParserCID, NS_DOMPARSER_CID);
/////////////////////////////////////////////
//
//
/////////////////////////////////////////////
nsSOAPMessage::nsSOAPMessage()
{
NS_INIT_ISUPPORTS();
}
nsSOAPMessage::~nsSOAPMessage()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPMessage,
nsISOAPMessage,
nsISecurityCheckedComponent)
/* attribute nsIDOMDocument message; */
NS_IMETHODIMP nsSOAPMessage::GetMessage(nsIDOMDocument * *aMessage)
{
NS_ENSURE_ARG_POINTER(aMessage);
*aMessage = mMessage;
NS_IF_ADDREF(*aMessage);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetMessage(nsIDOMDocument * aMessage)
{
mMessage = aMessage;
return NS_OK;
}
/* readonly attribute nsIDOMElement envelope; */
NS_IMETHODIMP nsSOAPMessage::GetEnvelope(nsIDOMElement * *aEnvelope)
{
NS_ENSURE_ARG_POINTER(aEnvelope);
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString name, namespaceURI;
root->GetLocalName(name);
root->GetNamespaceURI(namespaceURI);
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)
&& namespaceURI.Equals(nsSOAPUtils::kSOAPEnvURI))
{
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return NS_OK;
}
}
}
*aEnvelope = nsnull;
return NS_OK;
}
/* readonly attribute nsIDOMElement header; */
NS_IMETHODIMP nsSOAPMessage::GetHeader(nsIDOMElement * *aHeader)
{
NS_ENSURE_ARG_POINTER(aHeader);
nsCOMPtr<nsIDOMElement> env;
GetEnvelope(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kHeaderTagName,
aHeader);
}
else {
*aHeader = nsnull;
}
return NS_OK;
}
/* readonly attribute nsIDOMElement body; */
NS_IMETHODIMP nsSOAPMessage::GetBody(nsIDOMElement * *aBody)
{
NS_ENSURE_ARG_POINTER(aBody);
nsCOMPtr<nsIDOMElement> env;
GetEnvelope(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kBodyTagName,
aBody);
}
else {
*aBody = nsnull;
}
return NS_OK;
}
/* attribute DOMString actionURI; */
NS_IMETHODIMP nsSOAPMessage::GetActionURI(nsAWritableString & aActionURI)
{
NS_ENSURE_ARG_POINTER(&aActionURI);
aActionURI.Assign(mActionURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetActionURI(const nsAReadableString & aActionURI)
{
mActionURI.Assign(aActionURI);
return NS_OK;
}
/* readonly attribute AString methodName; */
NS_IMETHODIMP nsSOAPMessage::GetMethodName(nsAString & aMethodName)
{
NS_ENSURE_ARG_POINTER(&aMethodName);
nsCOMPtr<nsIDOMElement> body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetLocalName(aMethodName);
return NS_OK;
}
}
aMethodName.SetLength(0);
return NS_OK;
}
/* readonly attribute AString targetObjectURI; */
NS_IMETHODIMP nsSOAPMessage::GetTargetObjectURI(nsAString & aTargetObjectURI)
{
NS_ENSURE_ARG_POINTER(&aTargetObjectURI);
nsCOMPtr<nsIDOMElement> body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetNamespaceURI(aTargetObjectURI);
return NS_OK;
}
}
aTargetObjectURI.SetLength(0);
return NS_OK;
}
NS_NAMED_LITERAL_STRING(kEmptySOAPDocStr, "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body></SOAP-ENV:Body></SOAP-ENV:Envelope>");
/* void encode (in AString aMethodName, in AString aTargetObjectURI, in PRUint32 aHeaderBlockCount, [array, size_is (aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks, in PRUint32 aParameterCount, [array, size_is (aParameterCount)] in nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::Encode(const nsAString & aMethodName, const nsAString & aTargetObjectURI, PRUint32 aHeaderBlockCount, nsISOAPHeaderBlock **aHeaderBlocks, PRUint32 aParameterCount, nsISOAPParameter **aParameters)
{
// Construct the message skeleton
nsresult rv;
nsCOMPtr<nsIDOMNode> ignored;
nsCOMPtr<nsIDOMParser> parser = do_CreateInstance(kDOMParserCID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString docstr;
rv = parser->ParseFromString(kEmptySOAPDocStr.get(), "text/xml",
getter_AddRefs(mMessage));
if (NS_FAILED(rv)) return rv;
// Declare the default encoding if one exists
if (mEncoding) {
nsCOMPtr<nsIDOMElement> envelope;
rv = GetEnvelope(getter_AddRefs(envelope));
if (NS_FAILED(rv)) return rv;
if (envelope) {
nsAutoString enc;
mEncoding->GetStyleURI(enc);
envelope->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
// Encode and add headers, if any were specified
if (aHeaderBlockCount) {
nsCOMPtr<nsIDOMElement> parent;
rv = GetHeader(getter_AddRefs(parent));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
for (PRUint32 i = 0; i < aHeaderBlockCount; i++) {
header = aHeaderBlocks[i];
if (!header) return NS_ERROR_FAILURE;
rv = header->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = parent->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
element = do_QueryInterface(node1);
}
else {
rv = header->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = header->GetActorURI(actorURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
encoding = mEncoding;
}
rv = header->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = header->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, parent, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (!actorURI.IsEmpty()) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix, nsSOAPUtils::kActorAttribute, actorURI);
}
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
}
nsCOMPtr<nsIDOMElement> body;
rv = GetBody(getter_AddRefs(body));
if (NS_FAILED(rv)) return rv;
// Only produce a call element if mMethodName was non-empty
if (!aMethodName.IsEmpty()) {
nsCOMPtr<nsIDOMElement> call;
rv = mMessage->CreateElementNS(aTargetObjectURI, aMethodName, getter_AddRefs(call));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMNode> ignored;
rv = body->AppendChild(call, getter_AddRefs(ignored));
if (NS_FAILED(rv)) return rv;
body = call;
nsAutoString prefix;
rv = nsSOAPUtils::MakeNamespacePrefixFixed(body, aTargetObjectURI, prefix);
if (NS_FAILED(rv)) return rv;
if (!prefix.IsEmpty()) {
rv = body->SetPrefix(prefix);
if (NS_FAILED(rv)) return rv;
}
}
// Encode and add all of the parameters into the body
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPParameter> param;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
for (PRUint32 i = 0; i < aParameterCount; i++) {
param = aParameters[i];
if (!param) return NS_ERROR_FAILURE;
rv = param->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = body->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
element = do_QueryInterface(node1);
}
else {
rv = param->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = param->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = param->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
encoding = mEncoding;
}
rv = param->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = param->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, body, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
return NS_OK;
}
static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
/* void getHeaderBlocks (out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks); */
NS_IMETHODIMP nsSOAPMessage::GetHeaderBlocks(PRUint32 *aCount, nsISOAPHeaderBlock ***aHeaderBlocks)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
*aCount = 0;
*aHeaderBlocks = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, length * sizeof(**aHeaderBlocks));
}
element = next;
header = new nsSOAPHeaderBlock();
if (NS_FAILED(rv)) return rv;
// XXX can't addref a COMPTr
//NS_ADDREF(header);
(*aHeaderBlocks)[(*aCount)++] = header;
rv = header->SetElement(element);
if (NS_FAILED(rv)) return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, (*aCount) * sizeof(**aHeaderBlocks));
}
return NS_OK;
}
/* void getParameters (in boolean aDocumentStyle, out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::GetParameters(PRBool aDocumentStyle, PRUint32 *aCount, nsISOAPParameter ***aParameters)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
*aCount = 0;
*aParameters = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPParameter> param;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, length * sizeof(**aParameters));
}
element = next;
param = new nsSOAPParameter();
if (NS_FAILED(rv)) return rv;
// XXX can't addref a COMPTr
//NS_ADDREF(param);
(*aParameters)[(*aCount)++] = param;
rv = param->SetElement(element);
if (NS_FAILED(rv)) return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, (*aCount) * sizeof(**aParameters));
}
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPMessage::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
if (!mEncoding) {
mEncoding = new nsSOAPEncoding();
if (!mEncoding)
return NS_ERROR_OUT_OF_MEMORY;
}
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
return NS_OK;
}
static const char*kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPMessage::CanCreateWrapper(const nsIID * iid, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPMessage::CanCallMethod(const nsIID * iid, const PRUnichar*methodName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPMessage::CanGetProperty(const nsIID * iid, const PRUnichar*propertyName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPMessage::CanSetProperty(const nsIID * iid, const PRUnichar*propertyName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPMessage_h__
#define nsSOAPMessage_h__
#include "nsString.h"
#include "nsISOAPEncoding.h"
#include "nsISOAPMessage.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsISupportsArray.h"
#include "nsCOMPtr.h"
#include "nsIVariant.h"
class nsSOAPMessage : public nsISOAPMessage,
public nsISecurityCheckedComponent
{
public:
nsSOAPMessage();
virtual ~nsSOAPMessage();
NS_DECL_ISUPPORTS
// nsISOAPMessage
NS_DECL_NSISOAPMESSAGE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsCOMPtr<nsIDOMDocument> mMessage;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsString mActionURI;
};
#endif

View File

@@ -0,0 +1,271 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPParameter.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPParameter::nsSOAPParameter()
{
NS_INIT_ISUPPORTS();
}
nsSOAPParameter::~nsSOAPParameter()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPParameter,
nsISOAPParameter,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPParameter::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPParameter::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPParameter::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPParameter::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPParameter::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPParameter::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPParameter::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPParameter::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPParameter::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPParameter::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPParameter::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPParameter::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPParameter_h__
#define nsSOAPParameter_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPParameter.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPParameter : public nsISOAPParameter,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPParameter();
virtual ~nsSOAPParameter();
NS_DECL_ISUPPORTS
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@@ -0,0 +1,122 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPResponse.h"
#include "nsSOAPUtils.h"
#include "nsSOAPFault.h"
#include "nsISOAPParameter.h"
nsSOAPResponse::nsSOAPResponse()
{
}
nsSOAPResponse::~nsSOAPResponse()
{
/* destructor code */
}
NS_IMPL_ISUPPORTS_INHERITED1(nsSOAPResponse, nsSOAPMessage, nsISOAPResponse)
/* attribute nsISOAPCall respondingTo; */
NS_IMETHODIMP nsSOAPResponse::GetRespondingTo(nsISOAPCall * *aRespondingTo)
{
NS_ENSURE_ARG_POINTER(aRespondingTo);
*aRespondingTo = mRespondingTo;
NS_IF_ADDREF(*aRespondingTo);
return NS_OK;
}
NS_IMETHODIMP nsSOAPResponse::SetRespondingTo(nsISOAPCall * aRespondingTo)
{
mRespondingTo = aRespondingTo;
return NS_OK;
}
/* readonly attribute nsISOAPFault fault; */
NS_IMETHODIMP nsSOAPResponse::GetFault(nsISOAPFault * *aFault)
{
NS_ENSURE_ARG_POINTER(aFault);
nsCOMPtr<nsIDOMElement> body;
*aFault = nsnull;
GetBody(getter_AddRefs(body));
if (body) {
nsSOAPUtils::GetSpecificChildElement(body,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kFaultTagName,
getter_AddRefs(body));
if (body) {
*aFault = new nsSOAPFault(body);
if (!*aFault)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aFault);
}
}
else {
*aFault = nsnull;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPResponse::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPResponse::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPResponse::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPResponse::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPResponse_h__
#define nsSOAPResponse_h__
#include "nsString.h"
#include "nsSOAPCall.h"
#include "nsISOAPResponse.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPResponse : public nsSOAPMessage,
public nsISOAPResponse
{
public:
NS_DECL_ISUPPORTS
// nsISOAPResponse
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPResponse
NS_DECL_NSISOAPRESPONSE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsSOAPResponse();
virtual ~nsSOAPResponse();
protected:
nsCOMPtr<nsISOAPCall> mRespondingTo;
};
#endif

View File

@@ -0,0 +1,237 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsSOAPStruct.h"
#include "nsSOAPUtils.h"
#include "nsSupportsArray.h"
#include "nsIXPConnect.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsISOAPParameter.h"
#include "nsSOAPJSValue.h"
#include "jsapi.h"
NS_IMPL_ISUPPORTS3(nsSOAPStruct, nsISOAPStruct, nsIXPCScriptable, nsISecurityCheckedComponent)
nsSOAPStruct::nsSOAPStruct(): mMembers(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
}
nsSOAPStruct::~nsSOAPStruct()
{
/* destructor code */
delete mMembers;
}
class nsSOAPStructEnumerator : public nsISimpleEnumerator
{
public:
NS_DECL_ISUPPORTS
// nsISimpleEnumerator methods:
NS_DECL_NSISIMPLEENUMERATOR
// nsSOAPStructEnumerator methods:
nsSOAPStructEnumerator(nsSOAPStruct* aStruct);
virtual ~nsSOAPStructEnumerator();
protected:
nsCOMPtr<nsSupportsArray> mMembers;
PRUint32 mCurrent;
};
PRBool StructEnumFunc(nsHashKey *aKey, void *aData, void* aClosure)
{
nsISupportsArray* members = NS_STATIC_CAST(nsISupportsArray*,aClosure);
nsISOAPParameter* parameter = NS_STATIC_CAST(nsISOAPParameter*,aData);
members->AppendElement(parameter);
return PR_TRUE;
}
nsSOAPStructEnumerator::nsSOAPStructEnumerator(nsSOAPStruct* aStruct)
: mMembers(new nsSupportsArray()), mCurrent(0)
{
NS_INIT_REFCNT();
aStruct->mMembers->Enumerate(&StructEnumFunc, mMembers);
}
nsSOAPStructEnumerator::~nsSOAPStructEnumerator()
{
}
NS_IMPL_ISUPPORTS1(nsSOAPStructEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP nsSOAPStructEnumerator::GetNext(nsISupports** aItem)
{
NS_ENSURE_ARG_POINTER(aItem);
PRUint32 count;
mMembers->Count(&count);
if (mCurrent < count) {
*aItem = mMembers->ElementAt(mCurrent++);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsSOAPStructEnumerator::HasMoreElements(PRBool* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
PRUint32 count;
mMembers->Count(&count);
*aResult = mCurrent < count;
return NS_OK;
}
/* readonly attribute nsISimpleEnumerator members; */
NS_IMETHODIMP nsSOAPStruct::GetMembers(nsISimpleEnumerator * *aMembers)
{
NS_ENSURE_ARG_POINTER(aMembers);
*aMembers = new nsSOAPStructEnumerator(this);
if (aMembers) {
NS_ADDREF(*aMembers);
return NS_OK;
}
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP nsSOAPStruct::GetMember(const nsAReadableString& aName, nsISOAPParameter* *aMember)
{
NS_ENSURE_ARG_POINTER(aMember);
nsStringKey nameKey(aName);
*aMember = NS_STATIC_CAST(nsISOAPParameter*, mMembers->Get(&nameKey));
return NS_OK;
}
// The nsIXPCScriptable map declaration that will generate stubs for us...
#define XPC_MAP_CLASSNAME nsSOAPStruct
#define XPC_MAP_QUOTED_CLASSNAME "SOAPStruct"
#define XPC_MAP_WANT_SETPROPERTY
#define XPC_MAP_WANT_GETPROPERTY
#define XPC_MAP_FLAGS nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
nsIXPCScriptable::USE_JSSTUB_FOR_DELPROPERTY | \
nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY
#include "xpc_map_end.h" /* This will #undef the above */
NS_IMETHODIMP
nsSOAPStruct::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsval id, jsval *vp,
PRBool *_retval)
{
if (JSVAL_IS_STRING(id)) {
JSString* str = JSVAL_TO_STRING(id);
const PRUnichar* name = NS_REINTERPRET_CAST(const PRUnichar *,
JS_GetStringChars(str));
nsDependentString namestr(name);
nsStringKey nameKey(namestr);
nsCOMPtr<nsISOAPParameter> parameter = dont_AddRef(NS_STATIC_CAST(nsISOAPParameter*, mMembers->Get(&nameKey)));
if (parameter == nsnull)
return NS_OK;
nsAutoString type;
parameter->GetType(type);
nsCOMPtr<nsISupports> value;
parameter->GetValue(getter_AddRefs(value));
return nsSOAPJSValue::ConvertValueToJSVal(cx,
value,
type,
vp);
}
return NS_OK;
}
NS_IMETHODIMP
nsSOAPStruct::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsval id, jsval *vp,
PRBool *_retval)
{
if (JSVAL_IS_STRING(id)) {
JSString* str = JSVAL_TO_STRING(id);
const PRUnichar* name = NS_REINTERPRET_CAST(const PRUnichar *,
JS_GetStringChars(str));
nsDependentString namestr(name);
nsStringKey nameKey(namestr);
nsCOMPtr<nsISupports> value;
nsAutoString type;
nsresult rc = nsSOAPJSValue::ConvertJSValToValue(cx,
*vp,
getter_AddRefs(value),
type);
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsISOAPParameter> parameter = do_CreateInstance(NS_SOAPPARAMETER_CONTRACTID);
parameter->SetName(namestr);
parameter->SetValue(value);
parameter->SetType(type);
mMembers->Put(&nameKey, parameter);
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPStruct::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPStruct))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPStruct::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPStruct))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPStruct::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPStruct))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPStruct::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPStruct))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,62 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPStruct_h__
#define nsSOAPStruct_h__
#include "nsString.h"
#include "nsISOAPStruct.h"
#include "nsIXPCScriptable.h"
#include "nsISecurityCheckedComponent.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
class nsSOAPStructEnumerator;
class nsSOAPStruct : public nsISOAPStruct,
public nsIXPCScriptable,
public nsISecurityCheckedComponent
{
public:
nsSOAPStruct();
virtual ~nsSOAPStruct();
NS_DECL_ISUPPORTS
// nsISOAPStruct
NS_DECL_NSISOAPSTRUCT
// nsISOAPStruct
NS_DECL_NSIXPCSCRIPTABLE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsresult SetMember(nsISOAPParameter *member);
protected:
nsSupportsHashtable* mMembers;
friend nsSOAPStructEnumerator;
};
#endif

View File

@@ -0,0 +1,426 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPUtils.h"
#include "nsIDOMText.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsCOMPtr.h"
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEnvURI,"http://schemas.xmlsoap.org/soap/envelope/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEncodingURI,"http://schemas.xmlsoap.org/soap/encoding/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEnvPrefix,"SOAP-ENV");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEncodingPrefix,"SOAP-ENC");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSIURI,"http://www.w3.org/1999/XMLSchema-instance");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSDURI,"http://www.w3.org/1999/XMLSchema");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSIPrefix,"xsi");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSITypeAttribute,"type");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSDPrefix,"xsd");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEncodingStyleAttribute,"encodingStyle");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kActorAttribute,"actor");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEnvelopeTagName,"Envelope");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kHeaderTagName,"Header");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kBodyTagName,"Body");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultTagName,"Fault");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultCodeTagName,"faultcode");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultStringTagName,"faultstring");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultActorTagName,"faultactor");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultDetailTagName,"detail");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEncodingSeparator,"#");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kQualifiedSeparator,":");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceNamespaceURI, "htp://www.w3.org/2000/xmlns/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceURI, "htp://www.w3.org/XML/1998/namespace");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLPrefix, "xml:");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespacePrefix, "xmlns:");
void
nsSOAPUtils::GetSpecificChildElement(
nsIDOMElement *aParent,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
*aElement = nsnull;
GetFirstChildElement(aParent, getter_AddRefs(sibling));
if (sibling)
{
GetSpecificSiblingElement(sibling,
aNamespace, aType, aElement);
}
}
void
nsSOAPUtils::GetSpecificSiblingElement(
nsIDOMElement *aSibling,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
*aElement = nsnull;
sibling = aSibling;
do {
nsAutoString name, namespaceURI;
sibling->GetLocalName(name);
sibling->GetNamespaceURI(namespaceURI);
if (name.Equals(aType)
&& namespaceURI.Equals(nsSOAPUtils::kSOAPEnvURI))
{
*aElement = sibling;
NS_ADDREF(*aElement);
return;
}
nsCOMPtr<nsIDOMElement> temp = sibling;
GetNextSiblingElement(temp, getter_AddRefs(sibling));
} while (sibling);
}
void
nsSOAPUtils::GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement)
{
nsCOMPtr<nsIDOMNode> child;
*aElement = nsnull;
aParent->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
child->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
}
void
nsSOAPUtils::GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement)
{
nsCOMPtr<nsIDOMNode> sibling;
*aElement = nsnull;
GetNextSibling(aStart, getter_AddRefs(sibling));
while (sibling) {
PRUint16 type;
sibling->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
sibling->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = sibling;
GetNextSibling(temp, getter_AddRefs(sibling));
}
}
nsresult
nsSOAPUtils::GetElementTextContent(nsIDOMElement* aElement,
nsAWritableString& aText)
{
nsCOMPtr<nsIDOMNode> child;
nsAutoString rtext;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::TEXT_NODE == type
|| nsIDOMNode::CDATA_SECTION_NODE == type) {
nsCOMPtr<nsIDOMText> text = do_QueryInterface(child);
nsAutoString data;
text->GetData(data);
rtext.Append(data);
}
else if (nsIDOMNode::ELEMENT_NODE == type) {
return NS_ERROR_ILLEGAL_VALUE; // This was interpreted as a simple value, yet had complex content in it.
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
aText.Assign(rtext);
return NS_OK;
}
PRBool
nsSOAPUtils::HasChildElements(nsIDOMElement* aElement)
{
nsCOMPtr<nsIDOMNode> child;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
return PR_TRUE;
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
return PR_FALSE;
}
void
nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
{
nsCOMPtr<nsIDOMNode> last;
nsCOMPtr<nsIDOMNode> current;
PRUint16 type;
*aNext = nsnull;
last = aSibling;
last->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last->GetFirstChild(getter_AddRefs(current));
if (!last)
{
last->GetNextSibling(getter_AddRefs(current));
}
}
else {
last->GetNextSibling(getter_AddRefs(current));
}
while (!current)
{
last->GetParentNode(getter_AddRefs(current));
current->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last = current;
last->GetNextSibling(getter_AddRefs(current));
}
else {
current = nsnull;
break;
}
}
*aNext = current;
NS_IF_ADDREF(*aNext);
}
nsresult nsSOAPUtils::GetNamespaceURI(nsIDOMElement* aScope,
const nsAReadableString & aQName,
nsAWritableString & aURI)
{
aURI.Truncate(0);
PRInt32 i = aQName.FindChar(':');
if (i < 0) {
return NS_OK;
}
nsAutoString prefix;
aQName.Left(prefix, i);
if (prefix.Equals(kXMLPrefix)) {
aURI.Assign(kXMLNamespaceURI);
return NS_OK;
}
nsresult rc;
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString value;
while (current != nsnull) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (attrs) {
rc = attrs->GetNamedItemNS(kXMLNamespaceNamespaceURI, prefix, getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
if (temp != nsnull)
return temp->GetNodeValue(aURI);
}
rc = current->GetParentNode(getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
current = temp;
}
return NS_ERROR_FAILURE;
}
nsresult nsSOAPUtils::GetLocalName(const nsAReadableString & aQName,
nsAWritableString & aLocalName)
{
PRInt32 i = aQName.FindChar(':');
if (i < 0)
aLocalName = aQName;
else
aQName.Mid(aLocalName, i, aQName.Length() - i);
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
const nsAReadableString & aURI,
nsAWritableString & aPrefix)
{
// This may change for level 3 serialization, so be sure to gut this
// and call the standardized level 3 method when it is available.
aPrefix.Truncate(0);
if (aURI.IsEmpty())
return NS_OK;
if (aURI.Equals(nsSOAPUtils::kXMLNamespaceURI)) {
aPrefix.Assign(nsSOAPUtils::kXMLPrefix);
return NS_OK;
}
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString tstr;
nsresult rc;
PRUint32 maxns = 0; // Keep track of max generated NS
for (;;) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (attrs) {
PRUint32 i = 0;
for (;;)
{
attrs->Item(i++, getter_AddRefs(temp));
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(nsSOAPUtils::kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(aURI)) {
nsAutoString prefix;
rc = temp->GetLocalName(prefix);
if (NS_FAILED(rc)) return rc;
nsCOMPtr<nsIDOMNode> check = aScope;
PRBool hasDecl;
nsCOMPtr<nsIDOMElement> echeck;
while (check != current) { // Make sure prefix is not overridden
echeck = do_QueryInterface(check);
if (echeck) {
rc = echeck->HasAttributeNS(nsSOAPUtils::kXMLNamespaceNamespaceURI, prefix, &hasDecl);
if (NS_FAILED(rc)) return rc;
if (hasDecl)
break;
current->GetParentNode(getter_AddRefs(temp));
current = temp;
}
}
if (check == current) {
aPrefix.Assign(prefix);
return NS_OK;
}
}
rc = temp->GetLocalName(tstr);
if (NS_FAILED(rc))
return rc;
else { // Decode the generated namespace into a number
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
tstr.BeginReading(i1);
tstr.EndReading(i2);
if (i1 == i2 || *i1 != 'n')
continue;
i1++;
if (i1 == i2 || *i1 != 's')
continue;
i1++;
PRUint32 n = 0;
while (i1 != i2) {
PRUnichar c = *i1;
i1++;
if (c < '0' || c > '9') {
n = 0;
break;
}
n = n * 10 + (c - '0');
}
if (n > maxns)
maxns = n;
}
}
}
current->GetParentNode(getter_AddRefs(temp));
if (temp)
current = temp;
else
break;
}
// Create a unique prefix...
PRUint32 len = 3;
PRUint32 c = maxns + 1;
while (c >= 10) {
c = c / 10;
len++;
}
// Set the length and write it backwards since that's the easiest way..
aPrefix.SetLength(len);
nsWritingIterator<PRUnichar> i2;
aPrefix.EndWriting(i2);
c = maxns + 1;
while (c > 0) {
PRUint32 r = c % 10;
c = c / 10;
i2--;
*i2 = (PRUnichar)(r + '0');
}
i2--;
*i2 = 's';
i2--;
*i2 = 'n';
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefixFixed(nsIDOMElement* aScope,
const nsAReadableString & aURI,
nsAWritableString & aPrefix)
{
if (aURI.Equals(kSOAPEncodingURI))
aPrefix = kSOAPEncodingPrefix;
else if (aURI.Equals(kSOAPEnvURI))
aPrefix = kSOAPEnvPrefix;
else if (aURI.Equals(kXSIURI))
aPrefix = kXSIPrefix;
else if (aURI.Equals(kXSDURI))
aPrefix = kXSDPrefix;
else
return MakeNamespacePrefix(aScope, aURI, aPrefix);
return NS_OK;
}
PRBool nsSOAPUtils::StartsWith(nsAReadableString& aSuper,
nsAReadableString& aSub)
{
PRUint32 c1 = aSuper.Length();
PRUint32 c2 = aSub.Length();
if (c1 < c2) return PR_FALSE;
if (c1 == c2) return aSuper.Equals(aSub);
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
aSuper.BeginReading(i1);
aSub.BeginReading(i2);
while (c2--) {
if (*i1 != *i2) return PR_FALSE;
i1++;
i2++;
}
return PR_TRUE;
}

View File

@@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPUtils_h__
#define nsSOAPUtils_h__
#include "nsString.h"
#include "nsIDOMElement.h"
class nsSOAPUtils {
public:
static void GetSpecificChildElement(nsIDOMElement *aParent,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement);
static void GetSpecificSiblingElement(nsIDOMElement *aSibling,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement);
static void GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement);
static void GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement);
static nsresult GetElementTextContent(nsIDOMElement* aElement,
nsAWritableString& aText);
static PRBool HasChildElements(nsIDOMElement* aElement);
static void GetNextSibling(nsIDOMNode* aSibling,
nsIDOMNode **aNext);
static nsresult MakeNamespacePrefix(nsIDOMElement* aElement,
const nsAReadableString & aURI,
nsAWritableString & aPrefix);
static nsresult MakeNamespacePrefixFixed(nsIDOMElement* aElement,
const nsAReadableString & aURI,
nsAWritableString & aPrefix);
static nsresult GetNamespaceURI(nsIDOMElement* aElement,
const nsAReadableString & aQName,
nsAWritableString & aURI);
static nsresult GetLocalName(const nsAReadableString & aQName,
nsAWritableString & aLocalName);
// All those missing string functions have to come from somewhere...
static PRBool StartsWith(nsAReadableString& aSuper,
nsAReadableString& aSub);
static nsDependentString kSOAPEnvURI;
static nsDependentString kSOAPEncodingURI;
static nsDependentString kSOAPEnvPrefix;
static nsDependentString kSOAPEncodingPrefix;
static nsDependentString kXSIURI;
static nsDependentString kXSDURI;
static nsDependentString kXSIPrefix;
static nsDependentString kXSITypeAttribute;
static nsDependentString kXSDPrefix;
static nsDependentString kEncodingStyleAttribute;
static nsDependentString kActorAttribute;
static nsDependentString kEnvelopeTagName;
static nsDependentString kHeaderTagName;
static nsDependentString kBodyTagName;
static nsDependentString kFaultTagName;
static nsDependentString kFaultCodeTagName;
static nsDependentString kFaultStringTagName;
static nsDependentString kFaultActorTagName;
static nsDependentString kFaultDetailTagName;
static nsDependentString kEncodingSeparator;
static nsDependentString kQualifiedSeparator;
static nsDependentString kXMLNamespaceNamespaceURI;
static nsDependentString kXMLNamespaceURI;
static nsDependentString kXMLNamespacePrefix;
static nsDependentString kXMLPrefix;
};
// Used to support null strings.
inline PRBool AStringIsNull(const nsAReadableString& aString)
{
return aString.IsVoid() || aString.IsEmpty(); // Get rid of empty hack when string implementations support.
}
inline void SetAStringToNull(nsAWritableString& aString)
{
aString.Truncate();
aString.SetIsVoid(PR_TRUE);
}
#define NS_SOAP_ENSURE_ARG_STRING(arg) \
NS_ENSURE_FALSE(AStringIsNull(arg), NS_ERROR_INVALID_ARG)
#endif

View File

@@ -1,222 +0,0 @@
#! gmake
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express oqr
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is Rhino code, released
# May 6, 1998.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#
# Makefile for javascript in java.
#
# This makefile is intended for packaging releases, and probably isn't
# suitable for production use - it doesn't attempt to do understand
# java dependencies beyond the package level.
#
# The makefiles for the subdirectories included in this package are
# intended to be called by this makefile with the proper CLASSDIR,
# PATH_PREFIX etc. variables. Makefiles in subdirectories are
# actually executed in the toplevel directory, with the PATH_PREFIX
# variable set to the subdirectory where the makefile is located.
#
# Initial version courtesy Mike Ang.
# Next version by Mike McCabe
# Don't include SHELL define (per GNU manual recommendation) because it
# breaks WinNT (with GNU make) builds.
# SHELL = /bin/sh
# Some things we might want to tweek.
CLASSDIR = classes
PACKAGE_NAME = org.mozilla.javascript
PACKAGE_PATH = org/mozilla/javascript
# jar filenames and the directories that build them.
JS_JAR = js.jar
JS_DIR = $(PACKAGE_PATH)
JSTOOLS_JAR = jstools.jar
JSTOOLS_DIR = $(PACKAGE_PATH)/tools
JARS = $(JS_JAR) $(JSTOOLS_JAR)
# It's not polite to store toplevel files in a tarball or zip files.
# What is the name of the toplevel directory to store files in?
# XXX we should probably add versioning to this.
DIST_DIR = jsjava
# XXX test this with sj
# JAVAC = mgcj
JAVAC=javac
# We don't define JFLAGS but we do export it to child
# builds in case it's defined by the environment.
# To build optimized (with javac) say 'make JFLAGS=-O'
GZIP = gzip
ZIP = zip
UNZIP = unzip
# JFLAGS="-O -g:none"
# Shouldn't need to change anything below here.
# For Windows NT builds (under GNU make).
ifeq ($(OS_TARGET), WINNT)
CLASSPATHSEP = '\\;'
else
CLASSPATHSEP = :
endif
# Make compatibility - use these instead of gmake 'export VARIABLE'
EXPORTS = CLASSDIR=$(CLASSDIR) JAVAC=$(JAVAC) JFLAGS=$(JFLAGS) SHELL=$(SHELL) \
PACKAGE_PATH=$(PACKAGE_PATH) PACKAGE_NAME=$(PACKAGE_NAME)
helpmessage : FORCE
@echo 'Targets include:'
@echo ' all - make jars, examples'
@echo ' jars - make js.jar, jstools.jar'
@echo ' fast - quick-and-dirty "make jars", for development'
@echo ' examples - build the .class files in the examples directory'
@echo ' check - perform checks on the source.'
@echo ' clean - remove intermediate files'
@echo ' clobber - make clean, and remove .jar files'
@echo ' zip - make a distribution .zip file'
@echo ' zip-source - make a distribution .zip file, with source'
@echo ' tar - make a distribution .tar.gz file'
@echo ' tar-source - make a distribution .tar.gz, with source'
@echo
@echo 'Define OS_TARGET to "WINNT" to build on Windows NT with GNU make.'
@echo
@echo 'The make-based build system does not include graphical'
@echo 'debugger or Bean Scripting Framework support. To build with'
@echo 'these, use the Ant build tool.'
@echo
@echo 'Ant is available at http://jakarta.apache.org/ant/'
all : jars examples
jars : $(JARS)
fast : fast_$(JS_JAR) $(JSTOOLS_JAR)
# Always call the sub-Makefile - which may decide that the jar is up to date.
$(JS_JAR) : FORCE
$(MAKE) -f $(JS_DIR)/Makefile JAR=$(@) $(EXPORTS) \
PATH_PREFIX=$(JS_DIR) \
CLASSPATH=.
fast_$(JS_JAR) :
$(MAKE) -f $(JS_DIR)/Makefile JAR=$(JS_JAR) $(EXPORTS) \
PATH_PREFIX=$(JS_DIR) \
CLASSPATH=. \
fast
$(JSTOOLS_JAR) : $(JS_JAR) FORCE
$(MAKE) -f $(JSTOOLS_DIR)/Makefile JAR=$(@) $(EXPORTS) \
PATH_PREFIX=$(JSTOOLS_DIR) \
CLASSPATH=./$(JS_JAR)$(CLASSPATHSEP).
examples : $(JS_JAR) FORCE
$(MAKE) -f examples/Makefile $(EXPORTS) \
PATH_PREFIX=examples \
CLASSPATH=./$(JS_JAR)
# We ask the subdirs to update their MANIFESTs
MANIFEST : FORCE
$(MAKE) -f $(JS_DIR)/Makefile JAR=$(JS_JAR) $(EXPORTS) \
PATH_PREFIX=$(JS_DIR) $(JS_DIR)/MANIFEST
$(MAKE) -f $(JSTOOLS_DIR)/Makefile JAR=$(JSTOOLS_JAR) $(EXPORTS) \
PATH_PREFIX=$(JSTOOLS_DIR) $(JSTOOLS_DIR)/MANIFEST
$(MAKE) -f examples/Makefile $(EXPORTS) \
PATH_PREFIX=examples examples/MANIFEST
# so ls below always has something to work on
touch MANIFEST
# examples/Makefile doesn't get included in the
# MANIFEST file, (which is used to create the non-source distribution) so
# we include it here.
cat examples/MANIFEST $(JS_DIR)/MANIFEST \
$(JSTOOLS_DIR)/MANIFEST \
| xargs ls MANIFEST README.html \
$(JARS) \
Makefile examples/Makefile \
> $(@)
# Make a MANIFEST file containing only the binaries and documentation.
# This could be abstracted further...
MANIFEST_binonly : MANIFEST
cat examples/MANIFEST \
| xargs ls $(JARS) README.html MANIFEST > MANIFEST
# A subroutine - not intended to be called from outside the makefile.
do_zip :
# Make sure we get a fresh one
- rm -r $(DIST_DIR)
- mkdir $(DIST_DIR)
- rm $(DIST_DIR).zip
cat MANIFEST | xargs $(ZIP) -0 -q $(DIST_DIR).zip
mv $(DIST_DIR).zip $(DIST_DIR)
cd $(DIST_DIR) ; \
$(UNZIP) -q $(DIST_DIR).zip ; \
rm $(DIST_DIR).zip
$(ZIP) -r -9 -q $(DIST_DIR).zip $(DIST_DIR)
- rm -r $(DIST_DIR)
zip : check jars examples MANIFEST_binonly do_zip
zip-source : check jars examples MANIFEST do_zip
# A subroutine - not intended to be called from outside the makefile.
do_tar :
- rm -r $(DIST_DIR)
- mkdir $(DIST_DIR)
- rm $(DIST_DIR).tar $(DIST_DIR).tar.gz
cat MANIFEST | xargs tar cf $(DIST_DIR).tar
mv $(DIST_DIR).tar $(DIST_DIR)
cd $(DIST_DIR) ; \
tar xf $(DIST_DIR).tar ; \
rm $(DIST_DIR).tar
tar cf $(DIST_DIR).tar $(DIST_DIR)
- rm -r $(DIST_DIR)
$(GZIP) -9 $(DIST_DIR).tar
tar: check jars examples MANIFEST_binonly do_tar
tar-source : check jars examples MANIFEST do_tar
# These commands just get passed to the respective sub-Makefiles.
clean clobber check:
$(MAKE) -f $(JS_DIR)/Makefile $(EXPORTS) JAR=$(JS_JAR) \
PATH_PREFIX=$(JS_DIR) $(@)
$(MAKE) -f $(JSTOOLS_DIR)/Makefile $(EXPORTS) JAR=$(JSTOOLS_JAR) \
PATH_PREFIX=$(JSTOOLS_DIR) $(@)
$(MAKE) -f examples/Makefile $(EXPORTS) PATH_PREFIX=examples $(@)
#emulate .PHONY
FORCE :

View File

@@ -1,46 +0,0 @@
<html>
<!--
- The contents of this file are subject to the Netscape Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/NPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The Original Code is Rhino code, released
- May 6, 1999.
-
- The Initial Developer of the Original Code is Netscape
- Communications Corporation. Portions created by Netscape are
- Copyright (C) 1998-1999 Netscape Communications Corporation. All
- Rights Reserved.
-
- Contributor(s):
- Norris Boyd
-
- Alternatively, the contents of this file may be used under the
- terms of the GNU Public License (the "GPL"), in which case the
- provisions of the GPL are applicable instead of those above.
- If you wish to allow use of your version of this file only
- under the terms of the GPL and not to allow others to use your
- version of this file under the NPL, indicate your decision by
- deleting the provisions above and replace them with the notice
- and other provisions required by the GPL. If you do not delete
- the provisions above, a recipient may use your version of this
- file under either the NPL or the GPL.
-->
<body>
<h1>
<span CLASS=LXRSHORTDESC>
Rhino: JavaScript in Java<p>
</span>
</h1>
<span CLASS=LXRLONGDESC>
Rhino is an implementation of JavaScript in Java. Documentation can be found
<a href="http://www.mozilla.org/js/rhino/rhino.html">here</a>.
</span>
</body>
</html>

View File

@@ -1,22 +0,0 @@
apiClasses=\
src/org/mozilla/javascript/ClassDefinitionException.java,\
src/org/mozilla/javascript/ClassOutput.java,\
src/org/mozilla/javascript/Context.java,\
src/org/mozilla/javascript/ContextListener.java,\
src/org/mozilla/javascript/EcmaError.java,\
src/org/mozilla/javascript/ErrorReporter.java,\
src/org/mozilla/javascript/Function.java,\
src/org/mozilla/javascript/FunctionObject.java,\
src/org/mozilla/javascript/ImporterTopLevel.java,\
src/org/mozilla/javascript/JavaScriptException.java,\
src/org/mozilla/javascript/NotAFunctionException.java,\
src/org/mozilla/javascript/PropertyException.java,\
src/org/mozilla/javascript/Script.java,\
src/org/mozilla/javascript/Scriptable.java,\
src/org/mozilla/javascript/ScriptableObject.java,\
src/org/mozilla/javascript/SecuritySupport.java,\
src/org/mozilla/javascript/WrapHandler.java,\
src/org/mozilla/javascript/Wrapper.java,\
src/org/mozilla/javascript/Synchronizer.java,\
src/org/mozilla/javascript/serialize/ScriptableInputStream.java,\
src/org/mozilla/javascript/serialize/ScriptableOutputStream.java

View File

@@ -1 +0,0 @@
This version was built on @datestamp@.

View File

@@ -1,131 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Build file for Rhino using Ant (see http://jakarta.apache.org/ant/index.html)
Requires Ant version 1.2 or later
-->
<project name="Rhino" default="default" basedir=".">
<target name="properties">
<property name="name" value="rhino"/>
<property name="Name" value="Rhino"/>
<property name="version" value="1_5R4pre"/>
<property name="rhino.jar" value="js.jar"/>
<property name="debug" value="off"/>
<property name="src.dir" value="src"/>
<property name="toolsrc.dir" value="toolsrc"/>
<property name="src.examples" value="examples"/>
<property name="build.dir" value="./build"/>
<property name="build.dest" value="${build.dir}/classes"/>
<property name="dist.name" value="rhino${version}"/>
<property name="dist.dir" value="${build.dir}/${dist.name}"/>
<property name="dist.src" value="${dist.dir}/src"/>
<property name="dist.toolsrc" value="${dist.dir}/toolsrc"/>
<property name="dist.examples" value="${dist.dir}/examples"/>
<property name="dist.docs" value="${dist.dir}/docs"/>
<property name="dist.apidocs" value="${dist.docs}/apidocs"/>
<property name="dist.file" value="rhino${version}.zip"/>
<property file="apiClasses.properties"/>
<property name="docsrc.dir" value="docs"/>
<property name="dist.docsrc.dir" value="${src.dir}/docs"/>
</target>
<target name="init" depends="properties">
</target>
<target name="prepare" depends="init">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dest}"/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.src}"/>
<mkdir dir="${dist.toolsrc}"/>
<mkdir dir="${dist.examples}"/>
<mkdir dir="${dist.docs}"/>
<mkdir dir="${dist.apidocs}"/>
</target>
<target name="compile-src" depends="prepare">
<ant dir="${src.dir}"/>
</target>
<target name="compile-toolsrc" depends="prepare">
<ant dir="${toolsrc.dir}"/>
</target>
<target name="compile" depends="compile-src,compile-toolsrc"/>
<target name="jar" depends="compile">
<jar jarfile="${dist.dir}/${rhino.jar}"
basedir="${build.dest}"
manifest="${src.dir}/manifest" />
</target>
<target name="jar-src" depends="compile-src">
<jar jarfile="${dist.dir}/${rhino.jar}"
basedir="${build.dest}"
manifest="${src.dir}/manifest" />
</target>
<target name="copy-examples" depends="prepare">
<copy todir="${dist.examples}">
<fileset dir="${src.examples}" includes="*.java,*.js,*.html" />
</copy>
</target>
<target name="copy-misc" depends="prepare">
<tstamp/>
<filter token="datestamp" value="${TODAY}"/>
<copy todir="${dist.dir}" filtering="yes">
<fileset dir=".">
<patternset>
<include name="build.xml"/>
<include name="apiClasses.properties"/>
<include name="build-date"/>
</patternset>
</fileset>
</copy>
</target>
<target name="copy-all" depends="copy-examples,copy-misc">
</target>
<target name="copy-docs" depends="prepare">
<echo message="copy from ${docsrc.dir}"/>
<copy todir="${dist.docs}">
<fileset dir="${docsrc.dir}"
includes="**/*.html,**/*.jpg,**/*.gif" />
</copy>
</target>
<target name="javadoc" depends="compile,copy-docs">
<javadoc sourcefiles="${apiClasses}"
sourcepath="${src.dir}"
destdir="${dist.apidocs}"
overview="${dist.docs}/api.html"
version="true"
author="true"
public="true"
windowtitle="${Name}" />
</target>
<target name="dist" depends="copy-all,javadoc,jar">
<delete file="${dist.file}" />
<zip zipfile="${dist.file}"
basedir="${build.dir}"
includes="**"
excludes="classes/**" />
</target>
<target name="default">
<echo>
**** Building core only; for full distribution build, try "ant dist".
</echo>
<antcall target="jar-src"/>
</target>
</project>

View File

@@ -1,161 +0,0 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="Microsoft Word 97">
<TITLE>1</TITLE>
</HEAD>
<BODY>
<OL>
<B><FONT FACE="Arial" SIZE=5 COLOR="#000080"><LI>Using the Rhino JavaScript Debugger</LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The Mozilla Rhino JavaScript engine includes a source-level debugger for debugging JavaScript scripts. The debugger is itself a Java program which you may run as</P>
</FONT><FONT FACE="Arial" SIZE=2><P ALIGN="JUSTIFY">java org.mozilla.javascript.tools.debugger.JSDebugger [options] [filename.js] [script-arguments]</P>
</FONT><FONT SIZE=2><P ALIGN="JUSTIFY">where the options are the same as the shell.</P>
<OL>
<LI><A NAME="_Toc502165108"></FONT><B><FONT FACE="Arial" SIZE=4 COLOR="#000080">Features</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The Rhino JavaScript Debugger can debug scripts running in multiple threads and provides facilities to set and clear breakpoints, control execution, view variables, and evaluate arbitrary JavaScript code in the current scope of an executing script.</P>
<OL>
<LI><A NAME="_Toc502165109"></FONT><B><FONT FACE="Arial" COLOR="#000080">Console Window</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The debugger redirects the </FONT><FONT FACE="Arial" SIZE=2>System.out</FONT><FONT SIZE=2>, </FONT><FONT FACE="Arial" SIZE=2>System.in</FONT><FONT SIZE=2>, and </FONT><FONT FACE="Arial" SIZE=2>System.err</FONT><FONT SIZE=2> streams to an internal JavaScript console window which provides an editable command line for you to enter JavaScript code and view system output. The console window maintains a history of the commands you have entered. You may move backward and forward through the history list by pressing the Up/Down arrow keys on the keyboard.</P>
<LI><A NAME="_Toc502165110"></FONT><B><FONT FACE="Arial" COLOR="#000080">Opening Scripts</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">You may select the <B><I>File-&gt;Open</B></I> menu item on the menu bar to load JavaScript scripts contained in files. This action will display a file-selection dialog box prompting you for the location of a script to load. The selected file will be compiled and displayed in a new window.</P>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Running Scripts</LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">You may select the <B><I>File-&gt;Run</B></I> menu item on the menu bar to execute JavaScript scripts contained in files. This action will display a file-selection dialog box prompting you for the location of a script to execute. The loaded script will be run in a new thread and control will be given to the debugger on its first instruction.</P>
<LI><A NAME="_Toc502165111"></FONT><B><FONT FACE="Arial" COLOR="#000080">Controlling Execution</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The debugger provides the following facilities for you to control the execution of scripts you are debugging:</P>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Step Into</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To single step entering any function calls, you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Step Into </B></I>menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Step Into</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the F11 key on the keyboard</LI></P></UL>
<P ALIGN="JUSTIFY">Execution will resume. If the current line in the script contains a function call control will return to the debugger upon entry into the function. Otherwise control will return to the debugger at the next line in the current function.</P>
<OL>
<OL>
<OL>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Step Over</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To single step to the next line in the current function, you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Step Over</B></I> menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Step Over</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the F7 key on the keyboard</LI></P></UL>
<P ALIGN="JUSTIFY">Execution will resume but control will return to the debugger at the next line in the current function or top-level script.</P>
<OL>
<OL>
<OL>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Step Out</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To continue execution until the current function returns you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Step Out</B></I> menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Step Out</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the F8 key on the keyboard</LI></P></UL>
<P ALIGN="JUSTIFY">Execution will resume until the current function returns or a breakpoint is hit.</P>
<OL>
<OL>
<OL>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Go</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To resume execution of a script you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Go</B></I> menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Go</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the F5 key on the keyboard</LI></P></UL>
<P ALIGN="JUSTIFY">Execution will resume until a breakpoint is hit or the script completes.</P>
<P ALIGN="JUSTIFY">&nbsp;</P>
<OL>
<OL>
<OL>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Break</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To stop all running scripts and give control to the debugger you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Break</B></I> menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Break</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the Pause/Break key on the keyboard</LI></P></UL>
<OL>
<OL>
<OL>
<LI><A NAME="_Toc502165112"></FONT><B><FONT FACE="Arial" COLOR="#000080">Moving Up and Down the Stack</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The lower-left (dockable) pane in the debugger main window contains a combo-box labeled &quot;Context:&quot; which displays the current stack of the executing script. You may move up and down the stack by selecting an entry in the combo-box. When you select a stack frame the variables and watch windows are updated to reflect the names and values of the variables visible at that scope.</P>
<LI><A NAME="_Toc502165113"></FONT><B><FONT FACE="Arial" COLOR="#000080">Setting and Clearing Breakpoints</A></LI></OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The main desktop of the debugger contains file windows which display the contents of each script you are debugging. You may set a breakpoint in a script by doing one of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Place the cursor on the line at which you want to set a breakpoint and right-click with the mouse. This action will display a pop-up menu. Select the <B><I>Set Breakpoint</B></I> menu item. </LI></P>
<P ALIGN="JUSTIFY"><LI>Simply single-click on the line number of the line at which you want to set a breakpoint.</LI></P></UL>
<P ALIGN="JUSTIFY">If the selected line contains executable code a red dot will appear next to the line number and a breakpoint will be set at that location.</P>
<P ALIGN="JUSTIFY">You may set clear breakpoint in a script by doing one of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Place the cursor on the line at which you want to clear a breakpoint and right-click with the mouse. This action will display a pop-up menu. Select the <B><I>Clear Breakpoint</B></I> menu item. </LI></P>
<P ALIGN="JUSTIFY"><LI>Simply single-click on the red dot or the line number of the line at which you want to clear a breakpoint.</LI></P></UL>
<P ALIGN="JUSTIFY">The red dot will disappear and the breakpoint at that location will be cleared.</P>
<OL>
<OL>
<OL>
<LI><A NAME="_Toc502165114"></FONT><B><FONT FACE="Arial" COLOR="#000080">Viewing Variables</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The lower-left (dockable) pane in the debugger main window contains a tab-pane with two tabs, labeled &quot;this&quot; and &quot;Locals&quot;. Each pane contains a tree-table which displays the properties of the current object and currently visible local variables, respectively. </P>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>This</LI></OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The properties of the current object are displayed in the <B><I>this</B></I> table. If a property is itself a JavaScript object the property may be expanded to show its sub-properties. The <B><I>this</B></I> table is updated each time control returns to the debugger or when you change the stack location in the <B><I>Context:</B></I> window.</P>
<LI><A NAME="_Toc502165115"></FONT><B><FONT FACE="Arial" COLOR="#000080">Locals</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The local variables of the current function are displayed in the <B><I>Locals</B></I> table. If a variable is itself a JavaScript object the variable may be expanded to show its sub-properties. The <B><I>Locals</B></I> table is updated each time control returns to the debugger or when you change the stack location in the <B><I>Context:</B></I> window</P>
<LI><A NAME="_Toc502165116"></FONT><B><FONT FACE="Arial" COLOR="#000080">Watch Window</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">You may enter arbitrary JavaScript expressions in the <B><I>Watch:</B></I> table located in the lower-right (dockable) pane in the debugger main window. The expressions you enter are reevaluated in the current scope and their current values displayed each time control returns to the debugger or when you change the stack location in the <B><I>Context:</B></I> window.</P>
<LI><A NAME="_Toc502165117"></FONT><B><FONT FACE="Arial" COLOR="#000080">Evaluation Window</A></LI></OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The <B><I>Evaluate</B></I> pane located in the lower-right (dockable) pane in the debugger main window contains an editable command line where you may enter arbitrary JavaScript code. The code is evaluated in the context of the current stack frame. The window maintains a history of the commands you have entered. You may move backward or forward through the history by pressing the Up/Down arrow keys on the keyboard. </P>
</FONT></BODY>
</HTML>

View File

@@ -1,137 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (WinNT; U) [Netscape]">
<title>JavaScript API</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<h1>
Rhino API Reference.</h1></center>
<h4>
The Control API</h4>
These APIs provide methods for controlling the actions of JavaScript in
a host environment.
<ul>
<li>
<a href="org/mozilla/javascript/Context.html">Context</a> - Represents
the runtime context of an executing script. Has methods to associate the
JavaScript evaluation engine with a Java thread, set attributes of the
engine, and compile and evaluate scripts.</li>
<li>
<a href="org/mozilla/javascript/ContextListener.html">ContextListener</a>
- Allows embeddings to be notified of the creation, entering, exiting,
and releasing of Contexts. </li>
<li>
<a href="org/mozilla/javascript/Script.html">Script</a> - The result of
compiling a JavaScript script. Also encapsulates script execution.</li>
<li>
<a href="org/mozilla/javascript/ErrorReporter.html">ErrorReporter</a> -
This interface can be implemented to control the actions the JavaScript
engine takes when it encounters errors.</li>
<li>
<a href="org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
- Optional support routines that must be provided by embeddings implementing
security controls on scripts.</li>
<li>
<a href="org/mozilla/javascript/Wrapper.html">Wrapper</a> - Interface implemented
by objects wrapping other objects. Provides a method for recovering the
wrapped value.</li>
<li>
<a href="org/mozilla/javascript/WrapHandler.html">WrapHandler</a> - Interface
embedders can implement in order to control the way Java objects are wrapped
for use by JavaScript.</li>
<li>
<a href="org/mozilla/javascript/ClassOutput.html">ClassOutput</a> - Interface
embedders can implement in order to control the placement of generated
class bytecodes.</li>
<li>
<a href="org/mozilla/javascript/serialize/ScriptableOutputStream.html">ScriptableOutputStream</a> - This stream can be used to serialize JavaScript objects and functions.
</li>
<li>
<a href="org/mozilla/javascript/serialize/ScriptableInputStream.html">ScriptableInputStream</a> - This stream can be used to deserialize JavaScript objects and functions.
</li>
</ul>
<h4>
The Host Object API</h4>
These APIs provide support for adding objects specific to a particular
embedding of JavaScript in a host environment. Note that if you just want
to script existing Java classes, you should just use <a href="http://developer.netscape.com/library/documentation/communicator/jsguide4/livecon.htm">LiveConnect</a>.
It is also helpful to understand some of the implementation of the <a href="runtime.html">runtime</a>.
<ul>
<li>
<a href="org/mozilla/javascript/Scriptable.html">Scriptable</a> - All JavaScript
objects must implement this interface. Provides methods to access properties
and attributes of those properties, as well as other services required
of JavaScript objects.</li>
<li>
<a href="org/mozilla/javascript/Function.html">Function</a> - All JavaScript
functions must implement this interface. Extends Scriptable, adding methods
to support invocation.</li>
<li>
<a href="org/mozilla/javascript/ScriptableObject.html">ScriptableObject</a>
- A default implementation of Scriptable that may be extended. Implements
property and attribute storage and lookup and other default JavaScript
object behavior.</li>
<li>
<a href="org/mozilla/javascript/FunctionObject.html">FunctionObject</a>
- An implementation of Function that allows Java methods and constructors
to be used as JavaScript function objects.</li>
<li>
<a href="org/mozilla/javascript/ImporterTopLevel.html">ImporterTopLevel</a>
- Allows embeddings to use the importClass and importPackage functions.</li>
</ul>
<h4>
Exceptions</h4>
These exceptions are thrown by JavaScript.
<ul>
<li>
<a href="org/mozilla/javascript/JavaScriptException.html">JavaScriptException</a>
- Thrown from within JavaScript by the JavaScript 'throw' statement, or
by LiveConnect calls from JavaScript into Java. Wraps a JavaScript value.</li>
<li>
<a href="org/mozilla/javascript/ClassDefinitionException.html">ClassDefinitionException</a>
- Thrown if errors are detected while attempting to define a host object
from a Java class.</li>
<li>
<a href="org/mozilla/javascript/PropertyException.html">PropertyException</a>
- Thrown if errors are detected while attempting to define a property of
a host object from a Java class or method, or if a property is not found.</li>
<li>
<a href="org/mozilla/javascript/NotAFunctionException.html">NotAFunctionException</a>
- Thrown when attempting to call an object that is not a function.</li>
<li>
<a href="org/mozilla/javascript/EvaluatorException.html">EvaluatorException</a>
- An exception thrown when an error is detected during the execution of
a script. The default error reporter will throw EvaluatorExceptions when
an error is encountered.</li>
</ul>
<hr WIDTH="100%">
<br><a href="overview-summary.html">back to top</a>
</body>
</html>

View File

@@ -1,43 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (WinNT; U) [Netscape]">
<meta name="KeyWords" content="Rhino, JavaScript, Java, BSF, Apache">
<title>Rhino and BSF</title>
</head>
<body bgcolor="#FFFFFF">
<script src="owner.js"></script>
<center>
<h1>
Using Rhino with BSF and Apache</h1></center>
<script>document.write(owner());</script>
<br><script>
var d = new Date(document.lastModified);
document.write((d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear());
document.write('<br>');
</script>
<hr WIDTH="100%">
<br>The <a href="http://oss.software.ibm.com/developerworks/projects/bsf">Bean
Scripting Framework</a> (or BSF) was originally developed by IBM and now
published as open source. It provides a framework for using a number of
scripting languages with Java. Rhino is one of the supported languages.
<p>This framework has been embedded in a number of open source projects,
including the XSL processor <a href="http://xml.apache.org/xalan/index.html">Xalan</a>
and the XML/Java build tool <a href="http://jakarta.apache.org/ant/index.html">Ant</a>.
<p>You can download a version of <tt>bsf.jar</tt> from <a href="http://oss.software.ibm.com/developerworks/projects/bsf">http://oss.software.ibm.com/developerworks/projects/bsf</a>
that includes the <tt>com.ibm.bsf.engines.javascript.JavaScriptEngine</tt>
class. The current version is 2.2 release candidate at the time of this
writing. This version thus supports JavaScript through Rhino when used
with the <tt>js.jar</tt> file from either <tt>rhino15R1.zip</tt> or <tt>rhinoTip.zip</tt>.
<p>See <a href="http://xml.apache.org/xalan/extensions.html#ex-basic">Xalan-Java
Extensions</a> for more information on adding JavaScript to XSL and the
<a href="http://jakarta.apache.org/ant/jakarta-ant/docs/#script">Script
task</a> for using scripting in Ant build files.
<p><a href="index.html">back to top</a>
</body>
</html>

View File

@@ -1,24 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<meta name="KeyWords" content="Rhino, JavaScript, Java">
<title>Change Log</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<h1>
Change Log for Significant Rhino Changes</h1></center>
This is a log of significant changes since the release of Rhino 1.5 Release
3.
<p><i>None yet!</i>
<h3>
<hr WIDTH="100%"><br>
<a href="index.html">back to top</a></h3>
</body>
</html>

View File

@@ -1,98 +0,0 @@
<html>
<head>
<title>Debugger API for Rhino</title>
</head>
<body bgcolor="#FFFFFF">
<h1><center>Debugger API for Rhino</center></h1>
<p>
<font color="red"><center>This release of the Debugger API should be considered to be of Beta quality.</center></font>
<p>
The Debugger API for Rhino consists of a set of Java interfaces
which describes a high level debugger API and a default implementation of that
API.
<p>
Most of the API is in the <code>com.netscape.javascript.debug</code> package. It is built
upon low-level support built into the core engine in <code>com.netscape.javascript</code>.
<p>
The <code>com.netscape.javascript.debug</code> package includes an implementation of the Debugger API
interfaces outlined below. The class <code>com.netscape.javascript.debug.DebugManager.java</code>
implements the <a href="com/netscape/javascript/debug/IDebugManager.html">IDebugManager</a>
interface and <code>com.netscape.javascript.debug.SourceTextManagerImpl.java</code> implements
the <a href="com/netscape/javascript/SourceTextManager.html">SourceTextManager</a> interface.
<p>
The class <code>com.netscape.javascript.tools.shell.Main.java</code> provides an
example which invokes the Debugger API.
<p>
<hr>
<p>
The core interface of the API is <a href="com/netscape/javascript/debug/IDebugManager.html">IDebugManager</a>.
This interface provide the central point for interacting with the debug system.
It supports the setting of the following hooks:
<ul>
<li><a href="com/netscape/javascript/debug/IInterruptHook.html">IInterruptHook</a> for immediate interrupt.
<li><a href="com/netscape/javascript/debug/IInstructionHook.html">IInstructionHook</a> for breakpoints.
<li><a href="com/netscape/javascript/debug/IDebugBreakHook.html">IDebugBreakHook</a> for breaking on errors.
<li><a href="com/netscape/javascript/debug/IErrorReporter.html">IErrorReporter</a> for hooking into the error reporter system.
<li><a href="com/netscape/javascript/debug/IScriptHook.html">IScriptHook</a> for notification of script and function load and unload.
</ul>
Customers of the Debugger API can provide implementations of these hook
interfaces which can be passed to the <i>IDebugManager</i> in order receive
notification of the various events within the core JavaScript engine.
<p>
When hooks are called they are passed appropriate objects which are implemented
by the Debugger API to describe such things as <i>stack frames</i>,
<i> program counter locations</i>, etc. The interfaces for these objects are:
<ul>
<li><a href="com/netscape/javascript/debug/IThreadState.html">IThreadState</a> representing the state of the stopped thread.
<li><a href="com/netscape/javascript/debug/IStackFrame.html">IStackFrame</a> representing a stack frame.
<li><a href="com/netscape/javascript/debug/IPC.html">IPC</a> representing a program counter location.
<li><a href="com/netscape/javascript/debug/IScript.html">IScript</a> representing a compiled JavaScript script or function.
<li><a href="com/netscape/javascript/debug/ISourceLocation.html">ISourceLocation</a> representing a location in the souce code.
</ul>
<p>
<hr>
<p>
<a href="com/netscape/javascript/SourceTextManager.html">SourceTextManager</a>
is an interface used to supply a centralized location from which a debugger
client can access JavaScript source. It supports capturing source as it is
parsed by <i>Rhino</i>. Alternately, source can be fed to it by the
embedding; e.g. in a browser embedding where the JavaScript code is just a
part of the html source the browser can feed the entire source to the
<i>SourceTextManager</i> so that a debugger can 'see' the whole source and
not just the part that is fed to the JavaScript compiler.
<p>
<a href="com/netscape/javascript/SourceTextItem.html">SourceTextItem</a> is an
interface representing a single 'block' of source code text (typically this
is an entire source file). This may be pure JavaScript source, or may include
JavaScript source embedded in html or whatever. The point is that this is the
text that a debugger should show to a user while debugging the JavaScript code.
This interface supports incrementally updated content. This is specifically
useful in browser embeddings where text is received in blocks. In fact, in a
browser it is possible that some of the source on a page may be compiled
and run even before the entire content of the page has been received from a
server.
<p>
<hr>
<p>
<a href="com/netscape/javascript/debug/ILaunchableDebugger.html">ILaunchableDebugger</a>
is an interface that abstractly represents a debugger user interface. It is
defined to allow an embedding to request that a debugger be launched without
requiring that the embedding be coupled at compile time to a particular debugger
implementation.
<p>
<hr>
<h3>Limitations and unimplemented features</h3>
<ul>
<li>Data Watchpoints are not implemented.
<li>Catching exceptions thrown in JavaScript code is not implemented.
<li>Per context hooking is not implemented.
<li>Setting the debug level to any non-zero value forces the optimization level to zero.
<li>Tracking of calls to plain Java methods from JavaScript is not implemented.
<li>Running at debug level >= 6 causes JIT errors with the Symantec JVM (but no other JVMs)
<li>The Debug API has not been rigorously tested.
</ul>
<p>
<hr WIDTH="100%">
<br><A HREF="overview-summary.html">back to top</A>
</body>
</html>

View File

@@ -1,241 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (WinNT; I) [Netscape]">
<meta name="KeyWords" content="Rhino, JavaScript, Java, Debugger">
<title>Rhino Debugger</title>
</head>
<body bgcolor="#FFFFFF">
<script src="owner.js">
</script>
<center>
<h1>
Rhino JavaScript Debugger</h1></center>
Christopher Oliver
<br><script>document.write(owner());</script>
<br>6/28/2001
<center>
<hr WIDTH="100%"></center>
The Rhino JavaScript debugger is a GUI that allows debugging of interpreted
JavaScript scripts run in Rhino. Note that this debugger <i>will not</i>
work with JavaScript scripts run in the mozilla browser since Rhino is
not the engine used in such environments.
<p><img SRC="jsdebug.jpg" height=460 width=600>
<p>Current limitations:
<ul>
<li>
Requires JDK 1.2 or greater</li>
<li>
Requires js.jar from rhinoTip.zip</li>
<li>
No breakpoint menu</li>
</ul>
<b><font face="Arial"><font color="#000080"><font size=+2>Using the Rhino
JavaScript Debugger</font></font></font></b>
<p><font size=-1>The Mozilla Rhino JavaScript engine includes a source-level
debugger for debugging JavaScript scripts. The debugger is itself a Java
program which you may run as</font>
<ol><font face="Arial"><font size=-1>java org.mozilla.javascript.tools.debugger.Main
[options] [filename.js] [script-arguments]</font></font></ol>
<font size=-1>where the options are the same as the shell.</font>
<p><font size=-1>The Rhino JavaScript Debugger can debug scripts running
in multiple threads and provides facilities to set and clear breakpoints,
control execution, view variables, and evaluate arbitrary JavaScript code
in the current scope of an executing script.</font>
<p><a NAME="_Toc502165109"></a><b><font face="Arial"><font color="#000080"><font size=-1>Console
Window</font></font></font></b>
<br><font size=-1>The debugger redirects the <font face="Arial">System.out</font>,
<font face="Arial">System.in</font>,
and <font face="Arial">System.err</font> streams to an internal JavaScript
console window which provides an editable command line for you to enter
JavaScript code and view system output. The console window maintains a
history of the commands you have entered. You may move backward and forward
through the history list by pressing the Up/Down arrow keys on the keyboard.</font>
<br><a NAME="_Toc502165110"></a><b><font face="Arial"><font color="#000080"><font size=-1>Opening
Scripts</font></font></font></b>
<br><font size=-1>You may select the <b><i>File->Open</i></b> menu item
on the menu bar to load JavaScript scripts contained in files. This action
will display a file-selection dialog box prompting you for the location
of a script to load. The selected file will be compiled and displayed in
a new window.</font>
<br><a NAME="_RunningScripts"></a><b><font face="Arial"><font color="#000080"><font size=-1>Running
Scripts</font></font></font></b>
<br><font size=-1>You may select the <b><i>File->Run</i></b> menu item
on the menu bar to execute JavaScript scripts contained in files. This
action will display a file-selection dialog box prompting you for the location
of a script to execute. The loaded script will be run in a new thread and
control will be given to the debugger on its first instruction.</font>
<p><a NAME="_Toc502165111"></a><b><font face="Arial"><font color="#000080"><font size=+1>Controlling
Execution</font></font></font></b>
<br><font size=-1>The debugger provides the following facilities for you
to control the execution of scripts you are debugging:</font>
<p><b><font face="Arial"><font color="#000080">Step Into</font></font></b>
<br><font size=-1>To single step entering any function calls, you may do
any of the following:</font>
<ul>
<li>
<font size=-1>Select the <b><i>Debug->Step Into </i></b>menu item on the
menu bar</font></li>
<li>
<font size=-1>Press the <b><i>Step Into</i></b> button on the toolbar</font></li>
<li>
<font size=-1>Press the F11 key on the keyboard</font></li>
</ul>
<font size=-1>Execution will resume. If the current line in the script
contains a function call control will return to the debugger upon entry
into the function. Otherwise control will return to the debugger at the
next line in the current function.</font>
<p><b><font face="Arial"><font color="#000080">Step Over</font></font></b>
<br><font size=-1>To single step to the next line in the current function,
you may do any of the following:</font>
<ul>
<li>
<font size=-1>Select the <b><i>Debug->Step Over</i></b> menu item on the
menu bar</font></li>
<li>
<font size=-1>Press the <b><i>Step Over</i></b> button on the toolbar</font></li>
<li>
<font size=-1>Press the F7 key on the keyboard</font></li>
</ul>
<font size=-1>Execution will resume but control will return to the debugger
at the next line in the current function or top-level script.</font>
<p><b><font face="Arial"><font color="#000080">Step Out</font></font></b>
<br><font size=-1>To continue execution until the current function returns
you may do any of the following:</font>
<ul>
<li>
<font size=-1>Select the <b><i>Debug->Step Out</i></b> menu item on the
menu bar</font></li>
<li>
<font size=-1>Press the <b><i>Step Out</i></b> button on the toolbar</font></li>
<li>
<font size=-1>Press the F8 key on the keyboard</font></li>
</ul>
<font size=-1>Execution will resume until the current function returns
or a breakpoint is hit.</font>
<p><b><font face="Arial"><font color="#000080">Go</font></font></b>
<br><font size=-1>To resume execution of a script you may do any of the
following:</font>
<ul>
<li>
<font size=-1>Select the <b><i>Debug->Go</i></b> menu item on the menu
bar</font></li>
<li>
<font size=-1>Press the <b><i>Go</i></b> button on the toolbar</font></li>
<li>
<font size=-1>Press the F5 key on the keyboard</font></li>
</ul>
<font size=-1>Execution will resume until a breakpoint is hit or the script
completes.</font>
<p><b><font face="Arial"><font color="#000080">Break</font></font></b>
<br><font size=-1>To stop all running scripts and give control to the debugger
you may do any of the following:</font>
<ul>
<li>
<font size=-1>Select the <b><i>Debug->Break</i></b> menu item on the menu
bar</font></li>
<li>
<font size=-1>Press the <b><i>Break</i></b> button on the toolbar</font></li>
<li>
<font size=-1>Press the Pause/Break key on the keyboard</font></li>
</ul>
<a NAME="_RunningScripts"></a><b><font face="Arial"><font color="#000080"><font size=-1>Break
on Exceptions</font></font></font></b>
<br><font size=-1>To give control to the debugger whenever a JavaScript
is exception is thrown select the <b><i>Debug->Break on Exceptions</i></b>
checkbox from the menu bar.&nbsp; Whenever a JavaScript exception is thrown
by a script a message dialog will be displayed and control will be given
to the debugger at the location the exception is raised.</font>
<p><a NAME="_Toc502165112"></a><b><font face="Arial"><font color="#000080">Moving
Up and Down the Stack</font></font></b>
<br><font size=-1>The lower-left (dockable) pane in the debugger main window
contains a combo-box labeled "Context:" which displays the current stack
of the executing script. You may move up and down the stack by selecting
an entry in the combo-box. When you select a stack frame the variables
and watch windows are updated to reflect the names and values of the variables
visible at that scope.</font>
<p><a NAME="_Toc502165113"></a><b><font face="Arial"><font color="#000080">Setting
and Clearing Breakpoints</font></font></b>
<br><font size=-1>The main desktop of the debugger contains file windows
which display the contents of each script you are debugging. You may set
a breakpoint in a script by doing one of the following:</font>
<ul>
<li>
<font size=-1>Place the cursor on the line at which you want to set a breakpoint
and right-click with the mouse. This action will display a pop-up menu.
Select the <b><i>Set Breakpoint</i></b> menu item.</font></li>
<li>
<font size=-1>Simply single-click on the line number of the line at which
you want to set a breakpoint.</font></li>
</ul>
<font size=-1>If the selected line contains executable code a red dot will
appear next to the line number and a breakpoint will be set at that location.</font>
<p><font size=-1>You may clear breakpoint in a script by doing one of the
following:</font>
<ul>
<li>
<font size=-1>Place the cursor on the line at which you want to clear a
breakpoint and right-click with the mouse. This action will display a pop-up
menu. Select the <b><i>Clear Breakpoint</i></b> menu item.</font></li>
<li>
<font size=-1>Simply single-click on the red dot or the line number of
the line at which you want to clear a breakpoint.</font></li>
</ul>
<font size=-1>The red dot will disappear and the breakpoint at that location
will be cleared.</font>
<p><a NAME="_Toc502165114"></a><b><font face="Arial"><font color="#000080"><font size=+1>Viewing
Variables</font></font></font></b>
<br><font size=-1>The lower-left (dockable) pane in the debugger main window
contains a tab-pane with two tabs, labeled "this" and "Locals". Each pane
contains a tree-table which displays the properties of the current object
and currently visible local variables, respectively.</font>
<p><b><font face="Arial"><font color="#000080">This</font></font></b>
<br><font size=-1>The properties of the current object are displayed in
the
<b><i>this</i></b> table. If a property is itself a JavaScript object
the property may be expanded to show its sub-properties. The <b><i>this</i></b>
table is updated each time control returns to the debugger or when you
change the stack location in the <b><i>Context:</i></b> window.</font>
<p><b><font face="Arial"><font color="#000080">Locals</font></font></b>
<br><font size=-1>The local variables of the current function are displayed
in the <b><i>Locals</i></b> table. If a variable is itself a JavaScript
object the variable may be expanded to show its sub-properties. The <b><i>Locals</i></b>
table is updated each time control returns to the debugger or when you
change the stack location in the <b><i>Context:</i></b> window</font>
<p><a NAME="_Toc502165116"></a><b><font face="Arial"><font color="#000080">Watch
Window</font></font></b>
<br><font size=-1>You may enter arbitrary JavaScript expressions in the
<b><i>Watch:</i></b>
table located in the lower-right (dockable) pane in the debugger main window.
The expressions you enter are re-evaluated in the current scope and their
current values displayed each time control returns to the debugger or when
you change the stack location in the <b><i>Context:</i></b> window.</font>
<p><a NAME="_Toc502165117"></a><b><font face="Arial"><font color="#000080">Evaluation
Window</font></font></b>
<br><font size=-1>The <b><i>Evaluate</i></b> pane located in the lower-right
(dockable) pane in the debugger main window contains an editable command
line where you may enter arbitrary JavaScript code. The code is evaluated
in the context of the current stack frame. The window maintains a history
of the commands you have entered. You may move backward or forward through
the history by pressing the Up/Down arrow keys on the keyboard.</font>
</body>
</html>

View File

@@ -1,166 +0,0 @@
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<meta name="KeyWords" content="Rhino, JavaScript, Java">
<title>Rhino Documentation</title>
</head>
<body bgcolor="#ffffff">
<center>
<h1> Rhino Documentation</h1>
</center>
<b><i><font size="+1">General</font></i></b>
<table width="100%">
<tbody>
<tr>
<td><a href="overview.html">Overview</a>
</td>
<td>An overview of the JavaScript language and of Rhino.</td>
</tr>
<tr>
<td><a href="limits.html">Requirements and Limitations</a>
</td>
<td>What you must have to run Rhino; what Rhino cannot do.</td>
</tr>
<tr>
<td><a href="rhino15R3.html">What's new in 1.5R3</a>
</td>
<td>Changes since 1.5R2.</td>
</tr>
<tr>
<td><a href="debugger.html">Rhino Debugger</a>
</td>
<td>A debugger for debugging JavaScript running in Rhino.</td>
</tr>
<tr>
<td><a href="opt.html">Optimization</a>
</td>
<td>Details on the various optimization levels.</td>
</tr>
<tr>
<td><a href="http://sourceforge.net/projects/jscorba">JS/CORBA Adapter</a>
</td>
<td>Provides a mechanism for arbitrary JavaScript objects to interact
with each other transparently in a distributed JavaScript system using CORBA.</td>
</tr>
<tr>
<td><a href="bsf.html">Using Rhino with BSF and Apache</a>
</td>
<td>How to use Rhino with apps that support BSF.</td>
</tr>
<tr>
<td><a href="changes.html">Recent Changes</a>
</td>
<td>Describes recent changes to Rhino.</td>
</tr>
<tr>
<td><a href="faq.html">FAQ</a>
</td>
<td>Answers to frequently asked questions about Rhino.</td>
</tr>
<tr>
<td><a href="http://industry.java.sun.com/javaone/99/event/0,1768,629,00.html">
1999 JavaOne session on Rhino</a>
</td>
<td>A talk on Rhino with slides. Also see the <a href="javaone.html">followup</a>
.</td>
</tr>
<tr>
<td valign="Top"><a href="http://www.ociweb.com/jnb/archive/jnbMar2001.html">
Scripting Languages for Java</a>
<br>
</td>
<td valign="Top">An article comparing and contrasting Rhino and Jython.<br>
</td>
</tr>
</tbody>
</table>
<p><b><i><font size="+1">Writing Scripts</font></i></b>
<table width="100%">
<tbody>
<tr>
<td><a href="scriptjava.html">Scripting Java</a>
</td>
<td>How to use Rhino to script Java classes.</td>
</tr>
<tr>
<td><a href="perf.html">Performance Hints</a>
</td>
<td>Some tips on writing faster JavaScript code.</td>
</tr>
<tr>
<td><a href="tools.html">Tools</a>
</td>
<td>Some tools for developing JavaScript scripts.</td>
</tr>
</tbody>
</table>
</p>
<p><b><i><font size="+1">Embedding Rhino</font></i></b>
<table width="100%">
<tbody>
<tr>
<td><a href="tutorial.html">Embedding tutorial</a>
</td>
<td>A short tutorial on how to embed Rhino into your application.</td>
</tr>
<tr>
<td><a href="apidocs/index.html">API javadoc Reference</a>
</td>
<td>An annotated outline of the programming interface to Rhino (tip only).</td>
</tr>
<tr>
<td><a href="scopes.html">Scopes and Contexts</a>
</td>
<td>Describes how to use scopes and contexts for the best performance
and flexibility, with an eye toward multithreaded environments.</td>
</tr>
<tr>
<td><a href="serialization.html">Serialization</a>
</td>
<td>How to serialize JavaScript objects and functions in Rhino.</td>
</tr>
<tr>
<td><a href="runtime.html">Runtime</a>
</td>
<td>A brief description of the JavaScript runtime.</td>
</tr>
<tr>
<td><a href="footprint.html">Small Footprint</a>
</td>
<td>Hints for those interested in small-footprint embeddings.</td>
</tr>
<tr>
<td><a href="examples.html">Examples</a>
</td>
<td>A set of examples showing how to control the JavaScript engine and
build JavaScript host objects.</td>
</tr>
<tr>
<td><font color="#000000"><a href="http://www.mozilla.org/js/tests/library.html">
Testing</a>
</font></td>
<td>How to run the JavaScript test suite.</td>
</tr>
</tbody>
</table>
</p>
<h3>
<hr width="100%"><a href="index.html">back to top</a>
</h3>
</body>
</html>

View File

@@ -1,88 +0,0 @@
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<title>Rhino Downloads</title>
</head>
<body>
<center><b><font size="+3">Rhino Downloads</font></b></center>
<p>Rhino is available for download both in source and compiled form. </p>
<h3> Binaries</h3>
You can download binaries (JAR files) from <a href="ftp://ftp.mozilla.org/pub/js/">
ftp://ftp.mozilla.org/pub/js/</a>
. Rhino 1.5 Release 2 is the last qualified release. It is also possible to
download the latest rhino build that reflects newer features and bug fixes,
but has not been fully qualified. These zip files also include the source.
<p>If you are looking for <tt>js.jar</tt> for XSLT or for IBM's Bean Scripting
Framework (BSF), download one of the zip files below and unzip it. </p>
<ul>
<li> <a href="ftp://ftp.mozilla.org/pub/js/rhino15R3-rc2.zip">Rhino 1.5R3
(release candidate 2).</a>
</li>
<ul>
<li> <i><font size="-1"><a href="rhino15R3.html">Description of changes
from 1.5R2</a>
</font></i>.</li>
</ul>
<li> <a href="ftp://ftp.mozilla.org/pub/js/rhino15R2.zip">Rhino 1.5R2.</a>
</li>
<ul>
<li> <i><font size="-1"><a href="rhino15R2.html">Description of changes
from 1.5R1</a>
</font></i>.</li>
</ul>
<li> <a href="ftp://ftp.mozilla.org/pub/js/rhino15R1.zip">Rhino 1.5R1.</a>
</li>
<ul>
<li> <i><font size="-1"><a href="rhino15R1.html">Description of changes
from 1.4R3</a>
</font></i>.</li>
</ul>
<li> <a href="ftp://ftp.mozilla.org/pub/js/rhino14R3.zip">Rhino 1.4 Release
3</a>
.</li>
<li> <a href="ftp://ftp.mozilla.org/pub/js/rhinoLatest.zip">Latest Rhino
builds</a>
.</li>
<ul>
<li> <i><font size="-1"><a href="changes.html">Description of changes from
1.5R3</a>
</font></i>.</li>
</ul>
</ul>
<h3> Source</h3>
The source code for Rhino is available under <a href="http://www.mozilla.org/NPL/">
NPL 1.1</a>
. In addition to getting the source from the zip files above, the source
code for Rhino can be found in the CVS tree at mozilla/js/rhino. See&nbsp;
<a href="http://www.mozilla.org/cvs.html">source code via cvs</a>
for details on how to set up CVS, define your CVSROOT, and login. Once you've
done that, just execute the command
<pre>&nbsp;&nbsp;&nbsp; cvs co mozilla/js/rhino</pre>
to get the tip source.
<p>The current tip can also be viewed using LXR at <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/">
http://lxr.mozilla.org/mozilla/source/js/rhino/</a>
. </p>
<p> </p>
<hr width="100%"><a href="index.html">back to top</a>
<br>
&nbsp;
</body>
</html>

View File

@@ -1,278 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 97">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (WinNT; U) [Netscape]">
<title>Embedding Scripting Host in Business Applications</title>
</head>
<body link="#0000FF">
<b><font face="Arial"><font size=-1>Embedding
Scripting Host in Business Applications</font></font></b>
<p><b><font face="Arial"><font size=-1>Madhukumar Seshadri, <a href="http://www.cognizant.com)/">www.cognizant.com</a></font></font></b>
<br>&nbsp;
<br>&nbsp;
<p><font face="Arial"><font size=-1>With web browsers, continuing to rule
the human interface for applications, creating value by being ubiquitous,
few adoptions of rich technology thats getting brewed underneath, will
help designing business applications even though most of the current ones
are made with birds eye of the underlying technologies.</font></font>
<p><font face="Arial"><font size=-1>JavaScript is a scripting language
invented and developed by Netscape. The language was primarily designed
for creating lightweight programming for web browser extensions by exposing
the Document Object Model of an HTML page to the scripts. JavaScript is
becoming object oriented and getting adopted for server-side scripting.</font></font>
<p><font face="Arial"><font size=-1>JavaScript is also becoming a standard
in the scripting world as Netscape is working closely with ECMA (European
Computer Manufacturers Association) to make it as a standard scripting
language for the script world. The standards are published as ECMA Script.</font></font>
<p><font face="Arial"><font size=-1>JavaScript originally designed for
exposing the DOM (Document Object Model) standardized by World Wide Web
consortium (W3C), to help web page designers to control and manipulate
the pages dynamically. JavaScript engines were embedded in the browsers
and they execute those portions of the code embedded in the HTML pages.</font></font>
<p><font face="Arial"><font size=-1>In short, JavaScript engine embedded
in the browser allowed extensions or manipulations for DOM Object run time
for the HTML page by executing the scripts associated with them. In other
words, browser exposes its DOM object for the page to scripts for extensions
and dynamic manipulations of the same, using a language that the script
interpreter understands.</font></font>
<p><font face="Arial"><font size=-1>Can I do the same for my application
by exposing my custom business objects written in my middle-tier? Can I
allow user to my write JavaScript extensions for my objects and also be
host for executing those scripts?</font></font>
<p><font face="Arial"><font size=-1>JavaScript host runs times are available
as binaries written in major languages. Check out <a href="http://www.mozilla.org/js">www.mozilla.org/js</a>.
Spider Monkey and Rhino are open source JavaScripting engines available
from mozilla.</font></font>
<p><font face="Arial"><font size=-1>Microsoft implementation of ECMA Script
(ECMA Script is based on core JavaScript, created by Netscape) is called
JScript. Microsoft binaries of jscript engine can be downloaded from http://msdn.microsoft.com/scripting/.</font></font>
<p><font face="Arial"><font size=-1>This document doesnt explain the JavaScript
language in detail but explains how these scripting engines can be used
as host to expose business objects in the middle-tier and how the user
of these applications can extend it if needed using JavaScript.</font></font>
<p><font face="Arial"><font size=-1>The scripting engine Rhino (<a href="http://www.mozilla.org/js)">www.mozilla.org/rhino)</a>,
a javascript engine purely written in Java is one that I am going to use
for the testing the above.</font></font>
<p><font face="Arial"><font size=-1>Let us set some simple goals,</font></font>
<ul>
<li>
<font face="Arial"><font size=-1>Execute a plain JavaScript code and
use static Java object</font></font></li>
<li>
<font face="Arial"><font size=-1>Instantiate external objects (written
in Java) from the script and use them within the script</font></font></li>
</ul>
<br>&nbsp;
<br>&nbsp;
<p><font face="Arial"><font size=-1>Let us write a simple Javscript to
test the above set goals,</font></font>
<p><font face="Arial"><font size=-1><b>Fig 1</b> jshosttest.js</font></font>
<p><b><i><font face="Arial"><font size=-1>/* Test 1 */</font></font></i></b>
<br><b><i><font face="Arial"><font size=-1>/* Use a static Java Object
in the script */</font></font></i></b>
<p><font face="Arial"><font size=-1>function test1() {</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; var str;</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; str = '"Hello World";</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; return str;</font></font>
<br><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>var str = test1( );</font></font>
<br><font face="Arial"><font size=-1>//out is expected to be Java Object
exposed to the script scope</font></font>
<br><font face="Arial"><font size=-1>out.println ("JavaScript - Test 1
- " + str);</font></font>
<p><b><i><font face="Arial"><font size=-1>/* Test 2 */</font></font></i></b>
<p><b><i><font face="Arial"><font size=-1>/* Instantiate a Javaobject for
this scope and use it */</font></font></i></b>
<p><font face="Arial"><font size=-1>function test2(){</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; // create a Java
string buffer object from JavaScript and use its java instance</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; // This uses an
another Java object created for creating new objects within Java and</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; // brings the same
for JavaScript execution scope</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; // Refer _create.java
for more information</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; create.getInstance("java.lang.StringBuffer","buffer");</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; //JavaScript refers
the java object instance as buffer</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; out.println(buffer.toString());</font></font>
<br>&nbsp;&nbsp;&nbsp; <font face="Arial"><font size=-1>buffer.append("I
am a javaobject dynamically created and executed in JavaScript");</font></font>
<br>&nbsp;&nbsp;&nbsp; <font face="Arial"><font size=-1>return buffer.toString();</font></font>
<br><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>var str = test2();</font></font>
<br><font face="Arial"><font size=-1>out.println("From JavaScript - Test
2 " + str);</font></font>
<p><font face="Arial"><font size=-1>Let us write a simple Javahost Object
using the Rhino engine to execute the above script,</font></font>
<p><b><font face="Arial"><font size=-1>Fig 2.1 - JSHost.java</font></font></b>
<p><font face="Arial"><font size=-1>/**</font></font>
<br><font face="Arial"><font size=-1>* @author Madhukumar Seshadri</font></font>
<br><font face="Arial"><font size=-1>* @version</font></font>
<br><font face="Arial"><font size=-1>*/</font></font>
<p><font face="Arial"><font size=-1>import org.mozilla.javascript.*;</font></font>
<br><font face="Arial"><font size=-1>import java.io.*;</font></font>
<br><font face="Arial"><font size=-1>import java.lang.*;</font></font>
<br><i><font face="Arial"><font size=-1>// import com.xxx.xxx.*;</font></font></i>
<p><font face="Arial"><font size=-1>public class JSHost extends Object
{</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; /** Creates new
JSHost */</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; public JSHost()
{</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; }</font></font>
<p><i><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; /*** Executes
.js file ***/</font></font></i>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; public Object executeJS
(String jsfname){</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; //You can also
use evaluateReader</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; File fp = new File(jsfname);</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; String str_buff
=null;</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; try {</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
FileReader fr = new FileReader(jsfname);</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int length = (int) fp.length();</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
char cbuff[] = new char[(char)length];</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
fr.read(cbuff);</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
str_buff = new String(cbuff);</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; } catch(Exception
e) {</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
e.printStackTrace();</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; }</font></font>
<p><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; //Execute the .js
file content</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; return executeJSSource(str_buff);</font></font>
<br><font face="Arial"><font size=-1>}</font></font>
<p><i><font face="Arial"><font size=-1>/*** Executes javascript source
***/</font></font></i>
<br><font face="Arial"><font size=-1>public Object executeJSSource (String
jsbuff){</font></font>
<br><font face="Arial"><font size=-1>Object any=null;</font></font>
<br><font face="Arial"><font size=-1>try{</font></font>
<br><i><font face="Arial"><font size=-1>//Enter the Context</font></font></i>
<br><font face="Arial"><font size=-1><i>// Refer </i><u><font color="#0000FF">http://www.mozilla.org/js/rhino/tutorial.html</font></u></font></font>
<br><font face="Arial"><font size=-1>Context context = Context.enter();</font></font>
<br><i><font face="Arial"><font size=-1>// Get the execution scope</font></font></i>
<br><font face="Arial"><font size=-1>Scriptable scope = context.initStandardObjects(null);</font></font>
<p><i><font face="Arial"><font size=-1>//----------- For Test 1 - Get System.out
in scope</font></font></i>
<br><font face="Arial"><font size=-1>//Scriptable jObj1 = Context.toObject(System.out,
scope);</font></font>
<br><font face="Arial"><font size=-1>scope.put("out", scope, jObj1);</font></font>
<p><i><font face="Arial"><font size=-1>//------------ For Test 2 - Instantiate
Create Object and get that in scope</font></font></i>
<br><i><font face="Arial"><font size=-1>//Allow JScript to create Java
Objects</font></font></i>
<br><i><font face="Arial"><font size=-1>//Bring the _create object to context</font></font></i>
<br><font face="Arial"><font size=-1>_create create = new _create( );</font></font>
<br><i><font face="Arial"><font size=-1>//Register this context and scope
to this create object instance</font></font></i>
<br><font face="Arial"><font size=-1>create.registerContext(context,scope);</font></font>
<br><font face="Arial"><font size=-1>//Scriptable jObj2 = Context.toObject(_create,
scope);</font></font>
<br><font face="Arial"><font size=-1>scope.put("create",scope,create);</font></font>
<br><i><font face="Arial"><font size=-1>//Evaluate (or execute js)</font></font></i>
<br><font face="Arial"><font size=-1><i>//Refer </i><u><font color="#0000FF">http://www.mozilla.org/js/rhino/tutorial.html</font></u></font></font>
<br><font face="Arial"><font size=-1>any = context.evaluateString(scope,
jsbuff, "", 1, null);</font></font>
<br><i><font face="Arial"><font size=-1>//Exit the Context</font></font></i>
<br><font face="Arial"><font size=-1>context.exit( );</font></font>
<br><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>catch ( JavaScriptException jse) {</font></font>
<br><font face="Arial"><font size=-1>jse.printStackTrace();</font></font>
<br><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>return any;</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<br>&nbsp;
<br>&nbsp;
<p><font face="Arial"><font size=-1>Let us write a class for creating new
Java objects and bringing them to this script execution scope,</font></font>
<p><b><font face="Arial"><font size=-1>Fig 2.2 _create.java</font></font></b>
<p><i><font face="Arial"><font size=-1>/**</font></font></i>
<p><i><font face="Arial"><font size=-1>* @author Madhukumar</font></font></i>
<p><i><font face="Arial"><font size=-1>*/</font></font></i>
<p><font face="Arial"><font size=-1>import java.lang.Class;</font></font>
<p><font face="Arial"><font size=-1>import org.mozilla.javascript.*;</font></font>
<p><font face="Arial"><font size=-1>public class _create extends Object
{</font></font>
<p><font face="Arial"><font size=-1>static Context ptr = null;</font></font>
<p><font face="Arial"><font size=-1>static Scriptable scope =null;</font></font>
<p><font face="Arial"><font size=-1>public _create () { }</font></font>
<p><font face="Arial"><font size=-1>public void registerContext(Context
cptr, Scriptable sc){</font></font>
<p><font face="Arial"><font size=-1>ptr = cptr;</font></font>
<p><font face="Arial"><font size=-1>scope = sc;</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>public void getInstance(String classname,String
jsclassname) {</font></font>
<p><font face="Arial"><font size=-1>Object any=null;</font></font>
<p><font face="Arial"><font size=-1>try {</font></font>
<p><font face="Arial"><font size=-1>Class thisclass = Class.forName(classname);</font></font>
<p><font face="Arial"><font size=-1>any = thisclass.newInstance();</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>catch(Exception e){</font></font>
<p><font face="Arial"><font size=-1>e.printStackTrace();</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>if( ptr != null) {</font></font>
<p><font face="Arial"><font size=-1>if (scope !=null) {</font></font>
<p><i><font face="Arial"><font size=-1>//register created object for this
execution scope</font></font></i>
<p><font face="Arial"><font size=-1>scope.put(jsclassname,scope,any);</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<br>&nbsp;
<br>&nbsp;
<p><font face="Arial"><font size=-1>It is time to test the code, so let
us write a small object that will use the JSHost object,</font></font>
<p><b><font face="Arial"><font size=-1>Fig 3 - JSHosttest.java</font></font></b>
<p><font face="Arial"><font size=-1>/**</font></font>
<p><font face="Arial"><font size=-1>* @author Madhukumar</font></font>
<p><font face="Arial"><font size=-1>* @version</font></font>
<p><font face="Arial"><font size=-1>*/</font></font>
<p><font face="Arial"><font size=-1>public class JSHosttest extends Object
{</font></font>
<p><font face="Arial"><font size=-1>/** Creates new JSHostTest*/</font></font>
<p><font face="Arial"><font size=-1>public JSHosttest() {</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>public static void main (String args[]){</font></font>
<p><font face="Arial"><font size=-1>if (args.length &lt; 1) {</font></font>
<p><font face="Arial"><font size=-1>System.out.println("Usage - Java JSHosttest.class
&lt;js source file>");</font></font>
<p><font face="Arial"><font size=-1>return;</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>JSHost jsh = new JSHost();</font></font>
<p><font face="Arial"><font size=-1>System.out.println("Executing JavaScript
file - " + args[0]);</font></font>
<p><font face="Arial"><font size=-1>Object result = jsh.executeJS(args[0]);</font></font>
<p><font face="Arial"><font size=-1>if (result instanceof String){</font></font>
<p><font face="Arial"><font size=-1>System.out.println("Results - " + result);</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<p><font face="Arial"><font size=-1>}</font></font>
<br>&nbsp;
<br>&nbsp;
<p><font face="Arial"><font size=-1>For more explanations on the code execution,
please refer embedding tutorial <a href="http://www.mozilla.org/js/rhino/tutorial.html">http://www.mozilla.org/js/rhino/tutorial.html</a>
and for all documentation and examples on Rhino visit <a href="http://www.mozilla.org/rhino/doc.html">http://www.mozilla.org/rhino/doc.html</a>.</font></font>
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
</body>
</html>

View File

@@ -1,89 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (WinNT; U) [Netscape]">
<title>Rhino Examples</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<h1>
Rhino Examples</h1></center>
Examples have been provided that show how to control the JavaScript engine
and to implement scriptable host objects. All the examples are in the cvs
tree at <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/">mozilla/js/rhino/examples</a></tt>.
<br>&nbsp;
<h2>
Sample Scripts</h2>
The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/unique.js">unique.js</a></tt>
script allows printing unique lines from a file.
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/liveConnect.js">liveConnect.js</a></tt>
script shows a sample usage of LiveConnect (Java-to-JavaScript connectivity).
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/jsdoc.js">jsdoc.js</a></tt>
script is a JavaScript analog to Java's <tt>javadoc</tt>. It makes heavy
use of regular expressions.
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/checkParam.js">checkParam.js</a></tt>
script is a useful tool to check that <tt>@param</tt> tags in Java documentation
comments match the parameters in the corresponding Java method.
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/enum.js">enum.js</a></tt>
script is a good example of using a JavaAdapter to implement a Java interface
using a JavaScript object.
<p>The <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/NervousText.js">NervousText.js</a>
script is a JavaScript implementation of the famous NervousText applet
using JavaScript compiled to Java classes using <a href="jsc.html">jsc</a>.
It can be run in the HTML page <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/NervousText.html">NervousText.html</a>.
<br>&nbsp;
<h2>
Controlling the JavaScript Engine</h2>
<h4>
The RunScript class</h4>
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/RunScript.java">RunScript.java</a></tt>
is a simple program that executes a script from the command line.
<h4>
The Control class</h4>
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Control.java">Control.java</a></tt>
is a program that executes a simple script and then manipulates the result.
<h4>
JavaScript Shell</h4>
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Shell.java">Shell.java</a></tt>
is a program that executes JavaScript programs; it is a simplified version
of the shell in the <tt>tools</tt> package. The programs may be specified
as files on the command line or by typing interactively while the shell
is running.
<h4>
<b>Multithreaded Script Execution</b></h4>
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/DynamicScopes.java">DynamicScopes.java</a></tt>
is a program that creates a single global scope object and then shares
it across multiple threads. Sharing the global scope allows both information
to be shared across threads, and amortizes the cost of Context.initStandardObjects
by only performing that expensive operation once.
<br>&nbsp;
<h2>
Implementing Host Objects</h2>
First check out the <a href="http://www.mozilla.org/rhino/tutorial.html">tutorial</a>
if you haven't already.
<h4>
The Foo class - Extending ScriptableObject</h4>
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Foo.java">Foo.java</a></tt>
is a simple JavaScript host object that includes a property with an associated
action and a variable argument method.
<br>&nbsp;
<h4>
The Matrix class - Implementing Scriptable</h4>
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Matrix.java">Matrix.java</a></tt>
provides a simple multidimensional array by implementing the Scriptable
interface.
<br>&nbsp;
<h4>
The File class - An advanced example</h4>
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/File.java">File.java</a></tt>
extends ScriptableObject to provide a means of reading and writing files
from JavaScript. A more involved example of host object definition.
<p>
<hr WIDTH="100%">
<br><a href="index.html">back to top</a>
</body>
</html>

View File

@@ -1,52 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<meta name="KeyWords" content="Rhino, JavaScript, Java">
<title>Rhino FAQ</title>
</head>
<body bgcolor="#FFFFFF">
<script src="owner.js"></script>
<center>
<h1>
Frequently Asked Questions about Rhino</h1></center>
<script>document.write(owner());</script>
<br><script>
var d = new Date(document.lastModified);
document.write((d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear());
document.write('<br>');
</script>
<center>
<hr WIDTH="100%"></center>
<p><b><font size=+2>Q</font>.</b> <i>How do I create a Java array from
JavaScript?</i>
<p><b><font size=+2>A.</font></b> You must use Java reflection. For instance,
to create an array of java.lang.String of length five, do
<blockquote><tt>var stringArray = java.lang.reflect.Array.newInstance(java.lang.String,
5);</tt></blockquote>
Then if you wish to assign the string "hi" to the first element, simply
execute <tt>stringArray[0] = "hi"</tt>.
<p>Creating arrays of primitive types is slightly different: you must use
the TYPE field. For example, creating an array of seven ints can be done
with the code
<blockquote><tt>var intArray = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE,
7);</tt></blockquote>
<p><br><b><font size=+2>Q</font>.</b> <i>When I try to execute a script
I get the exception </i><tt>Required security context missing</tt><i>.
What's going on?</i>
<p><b><font size=+2>A.</font></b> You've likely missed placing the <tt>Security.properties</tt>
file in your class path at <tt>org.mozilla.javascript.resources</tt>.
<h3>
<hr WIDTH="100%"><br>
<a href="index.html">back to top</a></h3>
</body>
</html>

View File

@@ -1,48 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; U) [Netscape]">
<title>Small Footprint</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<h1>
Small Footprint</h1></center>
A few changes can be made to reduce the footprint of Rhino for embeddings
where space is at a premium. On a recent build, Rhino consumed 355,883
bytes of space for uncompressed class files. With various changes that
number can be reduced to 281,455 bytes.
<br>&nbsp;
<h3>
Tools</h3>
Most embeddings won't need any of the classes in <tt>org.mozilla.javascript.tools</tt>
or any of its subpackages.
<br>&nbsp;
<h3>
Regular Expressions</h3>
The package <tt>org.mozilla.javascript.regexp</tt> can be removed. Rhino
will continue to run, although it will not be able to execute any regular
expression matches. This change saves 37,792 bytes of class files.
<br>&nbsp;
<h3>
JavaAdapter</h3>
Implementing the JavaAdapter functionality requires the ability to generate
classes on the fly. Removing <tt>org.mozilla.javascript.JavaAdapter</tt> and all
the classes in package <tt>org.mozilla.classfile</tt> will disable this
functionality, but Rhino will otherwise run correctly. These changes save
36,636 bytes.
<br>&nbsp;
<h3>
Optimizer</h3>
It is possible to run Rhino with interpreter mode only, allowing you to remove
classes for classfile generation. Remove the classes in packages
<tt>org.mozilla.classfile</tt> and <tt>org.mozilla.javascript.optimizer</tt>.
<br>&nbsp;
<p>
<hr WIDTH="100%">
<br><a href="index.html">back to top</a>
</body>
</html>

View File

@@ -1,44 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<title>Help with Rhino</title>
</head>
<body>
<center><b><font size=+3>Help with Rhino</font></b></center>
<script src="owner.js"></script>
<p>Have a question that you can't find answer to in the <a href="doc.html">documentation</a>?
Here are some additional resources for help:
<br>&nbsp;
<h3>
<font size=+1>Newsgroup and Mail Gateway</font></h3>
The <a href="news:netscape.public.mozilla.jseng">netscape.public.mozilla.jseng</a>
newsgroup answers questions about both Rhino and the C implementation of
JavaScript. You can get to the newsgroup through a mail gateway. Send a
message with the subject "subscribe" to <a href="mailto:mozilla-jseng-request@mozilla.org?subject=subscribe">mozilla-jseng-request@mozilla.org</a>.
To post messages, send mail to <a href="mailto:mozilla-jseng@mozilla.org">mozilla-jseng@mozilla.org</a>.
To unsubscribe, mail with "unsubscribe" in the subject to <a href="mailto:mozilla-jseng-request@mozilla.org?subject=unsubscribe">mozilla-jseng-request@mozilla.org</a>.
<p>
To view archived messages, try <a href="http://groups.google.com/groups?q=netscape.public.mozilla.jseng&hl=en&lr=&safe=off&site=groups">Google groups</a> or
other newsgroup services.
<h3>
Bug System</h3>
Use <a href="http://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>
to enter bugs against Rhino. Note that Rhino has its own product category.
<br>&nbsp;
<h3>
Module Owner</h3>
The module owner,&nbsp;<script>document.write(owner());</script>
, can
be mailed for help as well, although he may copy his response to the newsgroup
to help others.
<p>
<hr WIDTH="100%"><a href="index.html">back to top</a>
<br>&nbsp;
<br>&nbsp;
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More