|
Axis 2 example source code file (RPCLitSWAProxyTests.java)
The Axis 2 RPCLitSWAProxyTests.java source code/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.axis2.jaxws.proxy; import org.apache.axis2.jaxws.provider.DataSourceImpl; import org.apache.axis2.jaxws.proxy.rpclitswa.sei.RPCLitSWA; import javax.activation.DataHandler; import javax.activation.DataSource; import javax.imageio.ImageIO; import javax.imageio.stream.FileImageInputStream; import javax.imageio.stream.ImageInputStream; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import javax.xml.ws.Dispatch; import javax.xml.ws.Holder; import javax.xml.ws.Service; import java.awt.Image; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import junit.framework.TestCase; public class RPCLitSWAProxyTests extends TestCase { private QName serviceName = new QName( "http://org/apache/axis2/jaxws/proxy/rpclitswa", "RPCLitSWAService"); private String axisEndpoint = "http://localhost:8080/axis2/services/RPCLitSWAService"; private QName portName = new QName("http://org/apache/axis2/jaxws/proxy/rpclitswa", "RPCLitSWA"); private String wsdlLocation = System.getProperty("basedir",".")+"/"+ "test/org/apache/axis2/jaxws/proxy/rpclitswa/META-INF/RPCLitSWA.wsdl"; private DataSource imageDS; public void setUp() throws Exception { String imageResourceDir = System.getProperty("basedir", ".") + "/" + "test-resources" + File.separator + "image"; //Create a DataSource from an image File file = new File(imageResourceDir + File.separator + "test.jpg"); ImageInputStream fiis = new FileImageInputStream(file); Image image = ImageIO.read(fiis); imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image); } /** * Utility method to get the proxy * @return RPCLit proxy * @throws MalformedURLException */ public RPCLitSWA getProxy() throws MalformedURLException { File wsdl= new File(wsdlLocation); assertTrue("WSDL does not exist:" + wsdlLocation,wsdl.exists()); URL wsdlUrl = wsdl.toURL(); Service service = Service.create(wsdlUrl, serviceName); Object proxy =service.getPort(portName, RPCLitSWA.class); BindingProvider p = (BindingProvider)proxy; p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint); return (RPCLitSWA)proxy; } /** * Utility Method to get a Dispatch<String> * @return * @throws MalformedURLException */ public Dispatch<String> getDispatch() throws MalformedURLException { File wsdl= new File(wsdlLocation); URL wsdlUrl = wsdl.toURL(); Service service = Service.create(null, serviceName); service.addPort(portName, null, axisEndpoint); Dispatch<String> dispatch = service.createDispatch(portName, String.class, Service.Mode.PAYLOAD); return dispatch; } public void testNOOP() { } /** * Simple test that ensures that we can echo a string to an rpc/lit web service * NOTE: * To enable this test, remove the _. * Once you do this, you can add the following code to OperationDescriptionImpl. * buildAttachmentInformation() * // TODO: Start HACK for RPCLitSWAProxyTest addPartAttachmentDescription("dummyAttachmentIN", new AttachmentDescriptionImpl(AttachmentType.SWA, new String[] {"text/plain"})); addPartAttachmentDescription("dummyAttachmentINOUT", new AttachmentDescriptionImpl(AttachmentType.SWA, new String[] {"image/jpeg"})); addPartAttachmentDescription("dummyAttachmentOUT", new AttachmentDescriptionImpl(AttachmentType.SWA, new String[] {"text/plain"})); // TODO: End HACK for RPCListSWAProxyTest */ public void testRPCLitSWAEcho() throws Exception { RPCLitSWA proxy = getProxy(); String request = "This is a not attachment data"; String attachmentIN = "Data for plain text attachment"; DataHandler attachmentINOUT = getImageDH(); Holder<DataHandler> attachmentINOUT_Holder = new Holder Other Axis 2 examples (source code examples)Here is a short list of links related to this Axis 2 RPCLitSWAProxyTests.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.