Changeset 1a7238e15c467fb7303a95a6bb99dd5fabe7b990
- Timestamp:
- 12/31/06 00:11:38
(2 years ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1167520298 +0100
- git-parent:
[a1f1bc5cfe94cb9e3adfdfb9566f0a563f8d89c6]
- git-author:
- Christopher Jung <bktheg@web.de> 1167520298 +0100
- Message:
Applet an die neue Webservice-API angepasst
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| re5910b8 |
r1a7238e |
|
| 22 | 22 | |
|---|
| 23 | 23 | import org.ksoap2.SoapEnvelope; |
|---|
| | 24 | import org.ksoap2.SoapFault; |
|---|
| 24 | 25 | import org.ksoap2.serialization.SoapObject; |
|---|
| | 26 | import org.ksoap2.serialization.SoapPrimitive; |
|---|
| 25 | 27 | import org.ksoap2.serialization.SoapSerializationEnvelope; |
|---|
| 26 | 28 | import org.ksoap2.transport.HttpTransportSE; |
|---|
| … | … | |
| 49 | 51 | new SoapObject("http://ds.drifting-souls.net/", "identifyShip"); |
|---|
| 50 | 52 | |
|---|
| 51 | | rpc.addProperty("sess", ServerConnector.getInstance().getSession()); |
|---|
| 52 | 53 | rpc.addProperty("shipid", String.valueOf(id) ); |
|---|
| 53 | 54 | |
|---|
| 54 | 55 | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| 55 | 56 | |
|---|
| 56 | | return envelope.getResult().toString(); |
|---|
| | 57 | try { |
|---|
| | 58 | return (String)envelope.getResponse(); |
|---|
| | 59 | } |
|---|
| | 60 | catch( SoapFault f ) { |
|---|
| | 61 | System.err.println(f); |
|---|
| | 62 | return null; |
|---|
| | 63 | } |
|---|
| 57 | 64 | } |
|---|
| 58 | 65 | |
|---|
| … | … | |
| 68 | 75 | new SoapObject("http://ds.drifting-souls.net/", "identifyBase"); |
|---|
| 69 | 76 | |
|---|
| 70 | | rpc.addProperty("sess", ServerConnector.getInstance().getSession()); |
|---|
| 71 | 77 | rpc.addProperty("baseid", String.valueOf(id) ); |
|---|
| 72 | 78 | |
|---|
| 73 | 79 | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| 74 | 80 | |
|---|
| 75 | | return envelope.getResult().toString(); |
|---|
| | 81 | try { |
|---|
| | 82 | return (String)envelope.getResponse(); |
|---|
| | 83 | } |
|---|
| | 84 | catch( SoapFault f ) { |
|---|
| | 85 | System.err.println(f); |
|---|
| | 86 | return null; |
|---|
| | 87 | } |
|---|
| 76 | 88 | } |
|---|
| 77 | 89 | |
|---|
| … | … | |
| 84 | 96 | SoapObject rpc = |
|---|
| 85 | 97 | new SoapObject("http://ds.drifting-souls.net/", "validateSessID"); |
|---|
| 86 | | |
|---|
| 87 | | rpc.addProperty("sess", ServerConnector.getInstance().getSession()); |
|---|
| 88 | | |
|---|
| 89 | | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| 90 | | |
|---|
| 91 | | String answer = envelope.getResult().toString(); |
|---|
| 92 | | |
|---|
| 93 | | if( answer.equals("1") ) { |
|---|
| 94 | | return true; |
|---|
| 95 | | } |
|---|
| 96 | | else { |
|---|
| | 98 | |
|---|
| | 99 | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| | 100 | |
|---|
| | 101 | try { |
|---|
| | 102 | return (Boolean)envelope.getResponse(); |
|---|
| | 103 | } |
|---|
| | 104 | catch( SoapFault f ) { |
|---|
| | 105 | System.err.println(f); |
|---|
| 97 | 106 | return false; |
|---|
| 98 | 107 | } |
|---|
| … | … | |
| 107 | 116 | SoapObject rpc = |
|---|
| 108 | 117 | new SoapObject("http://ds.drifting-souls.net/", "hasNewPM"); |
|---|
| 109 | | |
|---|
| 110 | | rpc.addProperty("sess", ServerConnector.getInstance().getSession()); |
|---|
| 111 | | |
|---|
| 112 | | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| 113 | | |
|---|
| 114 | | String answer = envelope.getResult().toString(); |
|---|
| 115 | | |
|---|
| 116 | | try { |
|---|
| 117 | | if( answer == null ) { |
|---|
| 118 | | answer = "0"; |
|---|
| 119 | | } |
|---|
| 120 | | |
|---|
| 121 | | return Integer.decode(answer).intValue(); |
|---|
| 122 | | } |
|---|
| 123 | | catch( NumberFormatException e ) { |
|---|
| 124 | | System.out.println("Ungueltiger Zahlenwert in SoapConnector::hasNewPM"); |
|---|
| 125 | | System.out.println("Fehlerbeschreibung: "+e.getClass().getName()+" "+e.getMessage()); |
|---|
| 126 | | |
|---|
| 127 | | return 0; |
|---|
| | 118 | |
|---|
| | 119 | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| | 120 | |
|---|
| | 121 | try { |
|---|
| | 122 | return (Integer)envelope.getResponse(); |
|---|
| | 123 | } |
|---|
| | 124 | catch( SoapFault f ) { |
|---|
| | 125 | System.err.println(f); |
|---|
| | 126 | return -1; |
|---|
| 128 | 127 | } |
|---|
| 129 | 128 | } |
|---|
| … | … | |
| 139 | 138 | new SoapObject("http://ds.drifting-souls.net/", "admin_execcmd"); |
|---|
| 140 | 139 | |
|---|
| 141 | | rpc.addProperty("sess", ServerConnector.getInstance().getSession()); |
|---|
| 142 | 140 | rpc.addProperty("command", command); |
|---|
| 143 | 141 | |
|---|
| 144 | 142 | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| 145 | 143 | |
|---|
| 146 | | return envelope.getResult().toString(); |
|---|
| | 144 | try { |
|---|
| | 145 | return (String)envelope.getResponse(); |
|---|
| | 146 | } |
|---|
| | 147 | catch( SoapFault f ) { |
|---|
| | 148 | System.err.println(f); |
|---|
| | 149 | return null; |
|---|
| | 150 | } |
|---|
| 147 | 151 | } |
|---|
| 148 | 152 | |
|---|
| … | … | |
| 156 | 160 | SoapObject rpc = |
|---|
| 157 | 161 | new SoapObject("http://ds.drifting-souls.net/", "admin_isAdmin"); |
|---|
| 158 | | |
|---|
| 159 | | rpc.addProperty("sess", ServerConnector.getInstance().getSession()); |
|---|
| 160 | | |
|---|
| 161 | | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| 162 | | |
|---|
| 163 | | String answer = envelope.getResult().toString(); |
|---|
| 164 | | |
|---|
| 165 | | if( answer.equals("1") ) { |
|---|
| 166 | | return true; |
|---|
| 167 | | } |
|---|
| 168 | | else { |
|---|
| | 162 | |
|---|
| | 163 | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| | 164 | |
|---|
| | 165 | try { |
|---|
| | 166 | return (Boolean)envelope.getResponse(); |
|---|
| | 167 | } |
|---|
| | 168 | catch( SoapFault f ) { |
|---|
| | 169 | System.err.println(f); |
|---|
| 169 | 170 | return false; |
|---|
| 170 | 171 | } |
|---|
| … | … | |
| 183 | 184 | public String getUserValue( String uservalue ) { |
|---|
| 184 | 185 | SoapObject rpc = |
|---|
| 185 | | new SoapObject("http://ds.drifting-souls.net/", "soap_getUserValue"); |
|---|
| 186 | | |
|---|
| 187 | | rpc.addProperty("sess", ServerConnector.getInstance().getSession()); |
|---|
| | 186 | new SoapObject("http://ds.drifting-souls.net/", "getUserValue"); |
|---|
| | 187 | |
|---|
| 188 | 188 | rpc.addProperty("uservalue", uservalue); |
|---|
| 189 | 189 | |
|---|
| 190 | 190 | SoapSerializationEnvelope envelope = soapCall(rpc); |
|---|
| 191 | | return envelope.getResult().toString(); |
|---|
| | 191 | try { |
|---|
| | 192 | return ((SoapPrimitive)envelope.getResponse()).toString(); |
|---|
| | 193 | } |
|---|
| | 194 | catch( SoapFault f ) { |
|---|
| | 195 | System.err.println(f); |
|---|
| | 196 | return null; |
|---|
| | 197 | } |
|---|
| 192 | 198 | } |
|---|
| 193 | 199 | |
|---|
| … | … | |
| 201 | 207 | public void setUserValue( String uservalue, String newvalue ) { |
|---|
| 202 | 208 | SoapObject rpc = |
|---|
| 203 | | new SoapObject("http://ds.drifting-souls.net/", "soap_setUserValue"); |
|---|
| 204 | | |
|---|
| 205 | | rpc.addProperty("sess", ServerConnector.getInstance().getSession()); |
|---|
| | 209 | new SoapObject("http://ds.drifting-souls.net/", "setUserValue"); |
|---|
| | 210 | |
|---|
| 206 | 211 | rpc.addProperty("uservalue", uservalue); |
|---|
| 207 | 212 | rpc.addProperty("newvalue", newvalue); |
|---|
| … | … | |
| 217 | 222 | */ |
|---|
| 218 | 223 | private SoapSerializationEnvelope soapCall( SoapObject rpc ) { |
|---|
| 219 | | SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10); |
|---|
| | 224 | SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); |
|---|
| 220 | 225 | |
|---|
| 221 | 226 | try { |
|---|
| 222 | 227 | envelope.bodyOut = rpc; |
|---|
| 223 | 228 | |
|---|
| 224 | | HttpTransportSE ht = new HttpTransportSE(ServerConnector.getInstance().getServerURL()+"php/interface.php"); |
|---|
| | 229 | String soapPath = "soap"; |
|---|
| | 230 | String sess = ServerConnector.getInstance().getSession(); |
|---|
| | 231 | if( sess != null && sess.length() > 0 ) { |
|---|
| | 232 | soapPath += "/"+sess; |
|---|
| | 233 | } |
|---|
| | 234 | |
|---|
| | 235 | HttpTransportSE ht = new HttpTransportSE(ServerConnector.getInstance().getServerURL()+soapPath+"/interface"); |
|---|
| 225 | 236 | |
|---|
| 226 | 237 | ht.call("http://ds.drifting-souls.net/#"+rpc.getName(), envelope); |
|---|
| … | … | |
| 228 | 239 | catch (Exception e) { |
|---|
| 229 | 240 | e.printStackTrace(); |
|---|
| 230 | | System.out.println("Error: "+e.toString()); |
|---|
| | 241 | System.err.println("Error: "+e.toString()); |
|---|
| 231 | 242 | } |
|---|
| 232 | 243 | |
|---|