1 23 24 package org.infoglue.deliver.util.webservices; 25 26 import javax.xml.namespace.QName ; 27 import javax.xml.rpc.ParameterMode ; 28 29 import org.apache.axis.client.Call; 30 import org.apache.axis.client.Service; 31 import org.apache.axis.encoding.XMLType; 32 import org.apache.axis.encoding.ser.BeanDeserializerFactory; 33 import org.apache.axis.encoding.ser.BeanSerializerFactory; 34 import org.infoglue.cms.entities.content.ContentVO; 35 import org.infoglue.cms.entities.content.ContentVersionVO; 36 37 41 42 public class InfoGlueWebServices 43 { 44 private String serviceUrl = ""; 45 46 private boolean isSuccessfull; 47 private String message; 48 49 52 53 public InfoGlueWebServices() 54 { 55 } 56 57 60 61 public String getServiceUrl() 62 { 63 return serviceUrl; 64 } 65 66 69 70 public void setServiceUrl(String serviceUrl) 71 { 72 this.serviceUrl = serviceUrl; 73 } 74 75 78 79 public Integer createContent(ContentVO contentVO, Integer parentContentId, Integer contentTypeDefinitionId, Integer repositoryId) 80 { 81 Integer newContentId = null; 82 83 try 84 { 85 Service service = new Service(); 86 Call call = (Call)service.createCall(); 87 88 String endpoint = this.serviceUrl; 89 90 call.setTargetEndpointAddress(endpoint); call.setOperationName(new QName ("http://soapinterop.org/", "createContent")); call.setEncodingStyle( "http://schemas.xmlsoap.org/soap/encoding/" ); 93 94 QName poqn = new QName ("http://www.soapinterop.org/ContentVO", "ContentVO"); 96 Class cls = ContentVO.class; 97 call.registerTypeMapping(cls, poqn, BeanSerializerFactory.class, BeanDeserializerFactory.class); 98 99 QName qnameAttachment = new QName ("urn:EchoAttachmentsService", "DataHandler"); 100 101 call.addParameter("contentVO", poqn, ParameterMode.IN); 102 call.addParameter("parentContentId", XMLType.XSD_INT, ParameterMode.IN); 103 call.addParameter("contentTypeDefinitionId", XMLType.XSD_INT, ParameterMode.IN); 104 call.addParameter("repositoryId", XMLType.XSD_INT, ParameterMode.IN); 105 106 call.setReturnType(XMLType.XSD_INT); 107 108 Object [] args = {contentVO, parentContentId, contentTypeDefinitionId, repositoryId}; 109 newContentId = (Integer )call.invoke(args); } 111 catch (Exception e) 112 { 113 e.printStackTrace(); 114 } 115 116 return newContentId; 117 } 118 119 122 123 public Integer createContentVersion(ContentVersionVO contentVersionVO, Integer contentId, Integer languageId) 124 { 125 Integer newContentVersionId = null; 126 127 try 128 { 129 Service service = new Service(); 130 Call call = (Call)service.createCall(); 131 132 String endpoint = this.serviceUrl; 133 134 call.setTargetEndpointAddress(endpoint); call.setOperationName(new QName ("http://soapinterop.org/", "createContentVersion")); call.setEncodingStyle( "http://schemas.xmlsoap.org/soap/encoding/" ); 137 138 QName poqn = new QName ("http://www.soapinterop.org/ContentVersionVO", "ContentVersionVO"); 140 Class cls = ContentVersionVO.class; 141 call.registerTypeMapping(cls, poqn, BeanSerializerFactory.class, BeanDeserializerFactory.class); 142 143 QName qnameAttachment = new QName ("urn:EchoAttachmentsService", "DataHandler"); 144 145 call.addParameter("contentVersionVO", poqn, ParameterMode.IN); 146 call.addParameter("contentId", XMLType.XSD_INT, ParameterMode.IN); 147 call.addParameter("languageId", XMLType.XSD_INT, ParameterMode.IN); 148 149 call.setReturnType(XMLType.XSD_INT); 150 151 Object [] args = {contentVersionVO, contentId, languageId}; 152 newContentVersionId = (Integer )call.invoke(args); } 154 catch (Exception e) 155 { 156 e.printStackTrace(); 157 } 158 159 return newContentVersionId; 160 } 161 162 163 164 167 168 public boolean getIsSuccessfull() 169 { 170 return this.isSuccessfull; 171 } 172 173 176 177 public void setIsSuccessfull(boolean isSuccessfull) 178 { 179 this.isSuccessfull = isSuccessfull; 180 } 181 182 185 186 public String getMessage() 187 { 188 return this.message; 189 } 190 191 194 195 public void setMessage(String message) 196 { 197 this.message = message; 198 } 199 } | Popular Tags |