package org.jboss.ws.samples.jaxws.client; import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.naming.InitialContext; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import javax.xml.ws.Service; import javax.xml.ws.handler.Handler; import javax.xml.ws.handler.MessageContext; import javax.xml.ws.soap.SOAPBinding; import org.jboss.ws.core.StubExt; import com.att.cio.commonheader.v3.WSCallback; import com.att.cio.commonheader.v3.WSContext; import com.att.cio.commonheader.v3.WSHeader; import com.att.cio.commonheader.v3.WSMessageData; import com.att.cio.commonheader.v3.WSResponseHeader; import com.att.cio.commonheader.v3.WSContext.WSNameValue; import com.att.cio.soapheader.inband.FooCallbackPollResponse; import com.att.cio.soapheader.inband.FooCallbackRequest; import com.att.cio.soapheader.inband.FooCallbackResponse; import com.att.cio.soapheader.inband.FooRequest; import com.att.cio.soapheader.inband.FooResponse; import com.att.cio.soapheader.inband.InBandSoapHeader; import com.att.cio.soapheader.inband.NoAccessRequest; import com.att.cio.soapheader.inband.NoAccessResponse; import com.att.cio.soapheader.inband.TestApplExceptionRequest; import com.att.cio.soapheader.inband.TestApplExceptionResponse; import com.att.cio.soapheader.inband.WSException; public class Client { static String cbURL = "http://dinsdale.mo.sbc.com:8080/MyCBURL/"; static int correlationId = 100; public static void main(String[] args) { try { QName serviceName = new QName("http://cio.att.com/soapheader/inband", "InBandSoapHeaderImplService"); //URL wsdlLocation = new URL("http://127.0.0.1:8080/hellosoapheader?wsdl"); URL wsdlLocation = new File("hellosoapheader.xml").toURL(); URL securityURL = new File("jboss-wsse-client.xml").toURL(); Service service = Service.create(wsdlLocation, serviceName); InBandSoapHeader port = (InBandSoapHeader)service.getPort(InBandSoapHeader.class); BindingProvider bp = (BindingProvider)port; SOAPBinding binding = (SOAPBinding)bp.getBinding(); ((StubExt) port).setSecurityConfig(securityURL.toExternalForm()); ((StubExt) port).setConfigName("Standard WSSecurity Client"); Map reqContext = bp.getRequestContext(); reqContext.put(BindingProvider.USERNAME_PROPERTY, "kermit"); reqContext.put(BindingProvider.PASSWORD_PROPERTY, "thefrog"); reqContext.put(StubExt.PROPERTY_AUTH_TYPE, StubExt.PROPERTY_AUTH_TYPE_WSSE); System.out.println("** Calling Foo w/no WSHeader"); FooRequest fooRequest = new FooRequest(); fooRequest.setBody("the Foo body"); try { FooResponse fooRespose = port.foo(fooRequest); System.out.println("Foo Response:" + fooRespose.getReturn()); } catch (WSException wse) { wse.printStackTrace(); } System.out.println("** Done with Foo"); System.out.println("** Calling NoAccess"); WSHeader header = new WSHeader(); WSContext ctx = new WSContext(); ctx.setFromAppId("From"); ctx.setToAppId("To"); ctx.setVersion(new WSContext.Version()); ctx.getVersion().setMajor(1); ctx.getVersion().setMinor(0); header.setWSContext(ctx); port.noAccess(header, new NoAccessRequest()); } catch (Exception e) { e.printStackTrace(); } } }