List of usage examples for javax.xml.namespace QName QName
public QName(final String namespaceURI, final String localPart)
QName
constructor specifying the Namespace URI and local part.
If the Namespace URI is null
, it is set to javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI .
From source file:GoogleSearch.java
public static void main(String args[]) throws Exception { URL url = new URL("http://api.google.com/GoogleSearch.wsdl"); QName serviceName = new QName("urn:GoogleSearch", "GoogleSearchService"); QName portName = new QName("urn:GoogleSearch", "GoogleSearchPort"); Service service = Service.create(url, serviceName); Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); SOAPMessage request = MessageFactory.newInstance().createMessage(null, new FileInputStream("yourGoogleKey.xml")); SOAPMessage response = dispatch.invoke(request); response.writeTo(System.out); }
From source file:example.Main.java
public static void main(String[] args) throws Exception { Class[] classes = new Class[3]; classes[0] = A.class; classes[1] = B.class; classes[2] = C.class; JAXBContext jc = JAXBContext.newInstance(classes); JAXBIntrospector ji = jc.createJAXBIntrospector(); Map<QName, Class> classByQName = new HashMap<QName, Class>(classes.length); for (Class clazz : classes) { QName qName = ji.getElementName(clazz.newInstance()); if (null != qName) { classByQName.put(qName, clazz); }/* www .java 2 s . c o m*/ } QName qName = new QName("http://www.example.com", "EH"); System.out.println(classByQName.get(qName)); }
From source file:AuthenticationHeader.java
public static void main(String[] args) { try {/*w ww . jav a2s.c o m*/ URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); JAXBContext context = JAXBContext.newInstance(AuthenticationHeader.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(header, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:ListMObjects.java
public static void main(String[] args) { System.out.println("Executing List MObjects"); try {//from w w w. ja v a2 s . c om URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsListMObjects request = new ParamsListMObjects(); SuccessListMObjects result = port.listMObjects(request, header); JAXBContext context = JAXBContext.newInstance(SuccessListMObjects.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:GetLead.java
public static void main(String[] args) { System.out.println("Executing Get Lead"); try {/*w w w . j av a 2 s .c o m*/ URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsGetLead request = new ParamsGetLead(); LeadKey key = new LeadKey(); key.setKeyType(LeadKeyRef.EMAIL); key.setKeyValue("t@t.com"); request.setLeadKey(key); SuccessGetLead result = port.getLead(request, header); JAXBContext context = JAXBContext.newInstance(SuccessGetLead.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:DescribeMObject.java
public static void main(String[] args) { System.out.println("Executing Describe MObject"); try {/* w ww .j av a2s . c o m*/ URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsDescribeMObject request = new ParamsDescribeMObject(); request.setObjectName("ActivityRecord"); SuccessDescribeMObject result = port.describeMObject(request, header); JAXBContext context = JAXBContext.newInstance(SuccessDescribeMObject.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:GetImportToListStatus.java
public static void main(String[] args) { System.out.println("Executing Get Import To List Status"); try {/*from ww w. j a va 2 s . com*/ URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsGetImportToListStatus request = new ParamsGetImportToListStatus(); request.setProgramName("Trav-Demo-Program"); request.setListName("Trav-Test-List"); SuccessGetImportToListStatus result = port.getImportToListStatus(request, header); JAXBContext context = JAXBContext.newInstance(SuccessGetImportToListStatus.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:DeleteMObjects.java
public static void main(String[] args) { System.out.println("Executing Delete MObjects"); try {/*from w w w. jav a2 s. c o m*/ URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsDeleteMObjects request = new ParamsDeleteMObjects(); MObject mobj = new MObject(); mobj.setType("Opportunity"); mobj.setId(4); MObject mobj2 = new MObject(); mobj2.setType("Opportunity"); mobj2.setId(7); ArrayOfMObject objList = new ArrayOfMObject(); objList.getMObjects().add(mobj); objList.getMObjects().add(mobj2); request.setMObjectList(objList); SuccessDeleteMObjects result = port.deleteMObjects(request, header); JAXBContext context = JAXBContext.newInstance(SuccessDeleteMObjects.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:getMObjects.java
public static void main(String[] args) { System.out.println("Executing Get MObjects"); try {//from ww w .ja v a 2 s .c o m URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsGetMObjects request = new ParamsGetMObjects(); request.setType("Program"); MObjCriteria criteria = new MObjCriteria(); criteria.setAttrName("Id"); criteria.setComparison(ComparisonEnum.LE); criteria.setAttrValue("1010"); MObjCriteria criteria2 = new MObjCriteria(); criteria2.setAttrName("Name"); criteria2.setComparison(ComparisonEnum.NE); criteria2.setAttrValue("elizprogramtest"); ArrayOfMObjCriteria mObjCriteria = new ArrayOfMObjCriteria(); mObjCriteria.getMObjCriterias().add(criteria); mObjCriteria.getMObjCriterias().add(criteria2); request.setMObjCriteriaList(mObjCriteria); SuccessGetMObjects result = port.getMObjects(request, header); JAXBContext context = JAXBContext.newInstance(SuccessGetMObjects.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:MergeLeads.java
public static void main(String[] args) { System.out.println("Executing Merge Lead"); try {/*from w ww . ja v a2 s .c o m*/ URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsMergeLeads request = new ParamsMergeLeads(); ArrayOfAttribute winningLeadArray = new ArrayOfAttribute(); Attribute winner = new Attribute(); winner.setAttrName("IDNUM"); winner.setAttrValue("2"); winningLeadArray.getAttributes().add(winner); request.setWinningLeadKeyList(winningLeadArray); ArrayOfAttribute losingLeadArray = new ArrayOfAttribute(); Attribute loser = new Attribute(); loser.setAttrName("IDNUM"); loser.setAttrValue("15"); losingLeadArray.getAttributes().add(loser); ArrayOfAttribute losingLeadArray2 = new ArrayOfAttribute(); Attribute loser2 = new Attribute(); loser2.setAttrName("IDNUM"); loser2.setAttrValue("16"); losingLeadArray2.getAttributes().add(loser2); ArrayOfKeyList losingKeyList = new ArrayOfKeyList(); losingKeyList.getKeyLists().add(losingLeadArray); losingKeyList.getKeyLists().add(losingLeadArray2); request.setLosingLeadKeyLists(losingKeyList); SuccessMergeLeads result = port.mergeLeads(request, header); JAXBContext context = JAXBContext.newInstance(SuccessMergeLeads.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }