Hi,

Jay SenSharma

Jay SenSharma

Here is a simple demo which explains how we can create a Complex JAXWS WebService using WebLogic Workshop.  Most of the instractions are mentioned in the below images, so nothing much to explain.

This example also demonstrates how we can export the JAXWS WebService WAR file from the WebLogic Workshop.

Step1).  Creating a WebService Project.

JAXWS_Workspace_Creation

JAXWS_Workspace_Creation

Creating_Project_In_Workshop

Creating_Project_In_Workshop

Chosing_Webservice_Project

Chosing_Webservice_Project

Other_Project_Facets

Other_Project_Facets

Project_WebModule_Next

Project_WebModule_Next

Step2). Coding BasicStruct.java code.

Creating_SimpleClass

Creating_SimpleClass

BasicStruct

BasicStruct

BasicStruct_Code

BasicStruct_Code

package misc;
public class BasicStruct {
	  private int intValue;
	  private String stringValue;
	  private String[] stringArray;
	  public int getIntValue() {
	    return intValue;
	  }
	  public void setIntValue(int intValue) {
	    this.intValue = intValue;
	  }
	  public String getStringValue() {
	    return stringValue;
	  }
	  public void setStringValue(String stringValue) {
	    this.stringValue = stringValue;
	  }
	  public String[] getStringArray() {
	    return stringArray;
	  }
	  public void setStringArray(String[] stringArray) {
	    this.stringArray = stringArray;
	  }
	  public String toString() {
	    return "IntValue="+intValue+", StringValue="+stringValue;
	  }
	}

Step3). Creating WebService.

Creating_WebService

Creating_WebService

Creating_ComplexJAXWS_Service

Creating_ComplexJAXWS_Service

Complex_JAXWS_Code

Complex_JAXWS_Code

package ws;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.Oneway;
import javax.jws.soap.SOAPBinding;

import misc.BasicStruct;
@WebService(serviceName="ComplexService",name="ComplexPortType",targetNamespace="http://middlewaremagic")
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,
             parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
public class ComplexJAXWS {
  @WebMethod()
  @Oneway
  public void echoVoid() {
    System.out.println("ntechoVoid called");
  }

  @WebMethod()
  @WebResult(name="EchoStructReturnMessage", targetNamespace="http://middlewaremagic/docLiteralBare")
  public BasicStruct echoStruct(BasicStruct struct){
    System.out.println("nt echoStruct called");
    return struct;
  }
}

Step4). Exporting  JAXWS Project WAR.

Exporting_WAR_File_For_JAXWS

Exporting_WAR_File_For_JAXWS

Exported_WAR_Location

Exported_WAR_Location

Step5). Running The WebService and Accessing WSDL: http://localhost:7001/TestJAXWSProject/ComplexService?wsdl

Running_JAXWS_On_Server

Running_JAXWS_On_Server

Choose_Correct_Server

Choose_Correct_Server

Chosing_Deployment_Domain

Chosing_Deployment_Domain

  <?xml version="1.0" encoding="UTF-8" ?>
- <!--  Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.3-07/10/2008 08:41 PM(bt).
  -->
- <!--  Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.3-07/10/2008 08:41 PM(bt).
  -->
- <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://middlewaremagic" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://middlewaremagic" name="ComplexService">
- <types>
- <xsd:schema>
  <xsd:import namespace="http://middlewaremagic/docLiteralBare" schemaLocation="http://localhost:7001/TestJAXWSProject/ComplexService?xsd=1" />
  </xsd:schema>
- <xsd:schema>
  <xsd:import namespace="http://middlewaremagic" schemaLocation="http://localhost:7001/TestJAXWSProject/ComplexService?xsd=2" />
  </xsd:schema>
  </types>
- <message name="echoVoid">
  <part name="parameters" element="tns:echoVoid" />
  </message>
- <message name="echoStruct">
  <part name="parameters" element="tns:echoStruct" />
  </message>
- <message name="echoStructResponse">
  <part name="parameters" element="tns:echoStructResponse" />
  </message>
- <portType name="ComplexPortType">
- <operation name="echoVoid">
  <input message="tns:echoVoid" />
  </operation>
- <operation name="echoStruct">
  <input message="tns:echoStruct" />
  <output message="tns:echoStructResponse" />
  </operation>
  </portType>
- <binding name="ComplexPortTypePortBinding" type="tns:ComplexPortType">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <operation name="echoVoid">
  <soap:operation soapAction="" />
- <input>
  <soap:body use="literal" />
  </input>
  </operation>
- <operation name="echoStruct">
  <soap:operation soapAction="" />
- <input>
  <soap:body use="literal" />
  </input>
- <output>
  <soap:body use="literal" />
  </output>
  </operation>
  </binding>
- <service name="ComplexService">
- <port name="ComplexPortTypePort" binding="tns:ComplexPortTypePortBinding">
  <soap:address location="http://localhost:7001/TestJAXWSProject/ComplexService" />
  </port>
  </service>
  </definitions>

.

.

Thanks

Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.