Tag: JAXWS

Creating a JAXWS ComplexType WebService Using Top to Bottom Approach

Hi,

Jay SenSharma

Jay SenSharma

Based on the query of one of Our Magic Subscriber “Mauricio” we are going to see how we can create a JAXWS WebService using Contract First (from WSDL) mechanism.  So basically in Top to Bottom approach (Contract First Approach). We already have an existing WSDL and based on that we want to create a WebService.  WebLogic provides a best utility to achieve the same. The utility is called as  “weblogic.wsee.tools.anttasks.WsdlcTask” using this utility we can create any kind of WebService from a WSDL just by specifying type=”JAXWS”  or  type=”JAXRPC” as an attribute to the above ANT task.

Suppose we already have a contract (WSDL) like following  “ComplexImpl.wsdl” which internally can contain some Complex Data Types as well… The Following WSDL contains a Complex Datatype as “BasicStruct

==============>

Step1). Create a directory somewhere in your file system like :   “/demos/TopDown” and then place the above WSDL inside this directory.

<?xml version="1.0" encoding="UTF-8"?>
<s0:definitions name="ComplexServiceDefinitions" targetNamespace="http://example.org" xmlns="" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://example.org" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/">
  <s0:types>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://example.org" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://example.org" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="java:examples.webservices.complex"/>
      <xs:element name="echoComplexType">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="struct" type="java:BasicStruct" xmlns:java="java:examples.webservices.complex"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="echoComplexTypeResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="EchoStructReturnMessage" type="java:BasicStruct" xmlns:java="java:examples.webservices.complex"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="echoInt">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="IntegerInput" type="xs:int"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="echoIntResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="IntegerOutput" type="xs:int"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="java:examples.webservices.complex" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://example.org" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:complexType name="BasicStruct">
        <xs:sequence>
          <xs:element minOccurs="1" name="IntValue" nillable="false" type="xs:int"/>
          <xs:element minOccurs="1" name="StringValue" nillable="true" type="xs:string"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="StringArray" nillable="true" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </s0:types>
  <s0:message name="echoComplexType">
    <s0:part element="s1:echoComplexType" name="parameters"/>
  </s0:message>
  <s0:message name="echoComplexTypeResponse">
    <s0:part element="s1:echoComplexTypeResponse" name="parameters"/>
  </s0:message>
  <s0:message name="echoInt">
    <s0:part element="s1:echoInt" name="parameters"/>
  </s0:message>
  <s0:message name="echoIntResponse">
    <s0:part element="s1:echoIntResponse" name="parameters"/>
  </s0:message>
  <s0:portType name="ComplexPortType">
    <s0:operation name="echoComplexType" parameterOrder="parameters">
      <s0:input message="s1:echoComplexType"/>
      <s0:output message="s1:echoComplexTypeResponse"/>
    </s0:operation>
    <s0:operation name="echoInt" parameterOrder="parameters">
      <s0:input message="s1:echoInt"/>
      <s0:output message="s1:echoIntResponse"/>
    </s0:operation>
  </s0:portType>
  <s0:binding name="ComplexServiceSoapBinding" type="s1:ComplexPortType">
    <s2:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <s0:operation name="echoComplexType">
      <s2:operation style="document"/>
      <s0:input>
        <s2:body parts="parameters" use="literal"/>
      </s0:input>
      <s0:output>
        <s2:body parts="parameters" use="literal"/>
      </s0:output>
    </s0:operation>
    <s0:operation name="echoInt">
      <s2:operation style="document"/>
      <s0:input>
        <s2:body parts="parameters" use="literal"/>
      </s0:input>
      <s0:output>
        <s2:body parts="parameters" use="literal"/>
      </s0:output>
    </s0:operation>
  </s0:binding>
  <s0:service name="ComplexService">
    <s0:port binding="s1:ComplexServiceSoapBinding" name="ComplexPortTypeSoapPort">
      <s2:address location="http://localhost:7001/ComplexImpl/ComplexImpl"/>
    </s0:port>
  </s0:service>
</s0:definitions>

Step2). Now write the following kind of ANT build script to use the WSDLC utility to create a dummy WebService with default implementation of Service Operations (Methods)

build.xml

<project name="GenerateWS" default="all">
<property name="build" value="output" />
<property name="adminurl" value="t3://localhost:7001" />
<property name="serverName" value="AdminServer" />
<property name="userName" value="weblogic" />
<property name="password" value="weblogic" />
<property name="ear.name" value="Complex_JAXWS_Ear" />

<taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask" />
<taskdef name="wsdlc" classname="weblogic.wsee.tools.anttasks.WsdlcTask"/>
<target name="all" depends="generate-from-wsdl,wait"/>

<target name="generate-from-wsdl">
     <wsdlc srcWsdl="ComplexImpl.wsdl"
            destJwsDir="jarJws"
            destImplDir="." type="JAXWS"
            packageName="ws"/>
</target>

<target name="wait">
    <echo message=" Now you need to provide your own Implementation for sayHello() of [[[ ws/ComplexService_ComplexPortTypeSoapPortImpl.java ]]]" />
    <echo message=" then you need to run 'ant deploy' to rebuild your edited Service and to Deploy it on the Server..." />
</target>

<target name="build-service">
     <mkdir dir="${build}/${ear.name}" />
     <jwsc srcdir="." destdir="${build}/${ear.name}">
          <jws file="ws/ComplexService_ComplexPortTypeSoapPortImpl.java" compiledWsdl="jarJws/ComplexImpl_wsdl.jar" type="JAXWS"/>
     </jwsc>
</target>

<target name="deploy" depends="build-service">
     <wldeploy action="deploy"
               source="${build}/${ear.name}" user="${userName}"
               password="${password}" verbose="true"
               failonerror="yes"
               adminurl="${adminurl}"
               targets="${serverName}" />
</target>

<target name="redeploy">
     <wldeploy action="redeploy"
               source="${build}/${ear.name}" user="${userName}"
               password="${password}" verbose="true"
               failonerror="yes"
               adminurl="${adminurl}"
               targets="${serverName}" />
</target>
</project>

Step3). Now  Open a command prompt then run the “. ./setWLSEnv.sh”  to set the CLASSPATH and PATH properly.

Run the “setWLSEnv.sh” by adding two DOTs separated by a single space …..before the actual script like following : (use ‘cd’ command to move inside the <BEA_HOME>/wlserver_10.3/server/bin) then run the following command….
.  ./setWLSEnv.sh

Note: the first DOT represents that set the Environment in the current Shell, AND the second ./ represents execute the script from the current directory.

Step4). Now as soon as you will run the  command like “ant -buildfile build.xml  generate-from-wsdl”  it will generate all the artifacts for your WebService and a Dummy WebService implementation.

ant -buildfile build.xml
Buildfile: build.xml

generate-from-wsdl:
    [wsdlc] Download file [ComplexImpl.wsdl] to /tmp/_ckr59b
    [wsdlc] srcWsdl is redefined as [ /tmp/_ckr59b/ComplexImpl.wsdl ]
    [wsdlc] Consider using <depends>/<produces> so that wsimport won't do unnecessary compilation
    [wsdlc] parsing WSDL...

    [wsdlc] [WARNING] src-resolve: Cannot resolve the name 'java:BasicStruct' to a(n) 'type definition' component.
    [wsdlc]   line 9 of file:/tmp/_ckr59b/ComplexImpl.wsdl#types?schema1

    [wsdlc] generating code...

    [wsdlc] compiling code...

    [wsdlc] Note: /demos/TopDown/jarJws/generated/ws/ComplexService.java uses unchecked or unsafe operations.
    [wsdlc] Note: Recompile with -Xlint:unchecked for details.
[AntUtil.deleteDir] Deleting directory /tmp/_ckr59b

wait:
     [echo]  Now you need to provide your own Implementation for sayHello() of [[[ ws/ComplexService_ComplexPortTypeSoapPortImpl.java ]]]
     [echo]  then you need to run 'ant deploy' to rebuild your edited Service and to Deploy it on the Server...

all:

BUILD SUCCESSFUL
Total time: 3 seconds

Step5). Inside “/demos/TopDown/ws” you will find a WebService implementation class is generated with some name like “ComplexPortTypeSoapPortImpl.java” this is actually our WebService like following:

NOTE: A JAR also will be generated inside “/demos/TopDown/jarJws/ComplexImpl_wsdl.jar” this JAR will basically contain all the required classes and the Complex Datatypes which is going to be used by the WebService.


package ws;

import javax.jws.WebService;
import javax.xml.ws.BindingType;

/**
 * This class was generated by the JAX-WS RI.
 * Oracle JAX-WS 2.1.3-06/19/2008 07:03 PM(bt)
 * Generated source version: 2.1
 *
 */
@WebService(portName = "ComplexPortTypeSoapPort", serviceName = "ComplexService", targetNamespace = "http://example.org", wsdlLocation = "/wsdls/ComplexImpl.wsdl", endpointInterface = "ws.ComplexPortType")
@BindingType("http://schemas.xmlsoap.org/wsdl/soap/http")
public class ComplexService_ComplexPortTypeSoapPortImpl
    implements ComplexPortType
{

    public ComplexService_ComplexPortTypeSoapPortImpl() {
    }

    /**
     *
     * @param struct
     * @return
     *     returns ws.BasicStruct
     */
    public BasicStruct echoComplexType(BasicStruct struct) {
        //replace with your impl here
        return null;
    }

    /**
     *
     * @param integerInput
     * @return
     *     returns int
     */
    public int echoInt(int integerInput) {
        //replace with your impl here
        return 0;
    }

}

Step6).Now We need to just add our Business implementation according to our requirement inside the methods present inside the WebService “ComplexPortTypeSoapPortImpl.java”  like following:

package ws;
import javax.jws.WebService;
import javax.xml.ws.BindingType;

/**
 * This class was generated by the JAX-WS RI.
 * Oracle JAX-WS 2.1.3-06/19/2008 07:03 PM(bt)
 * Generated source version: 2.1
 *
 */
@WebService(portName = "ComplexPortTypeSoapPort", serviceName = "ComplexService", targetNamespace = "http://example.org", wsdlLocation = "/wsdls/ComplexImpl.wsdl", endpointInterface = "ws.ComplexPortType")
@BindingType("http://schemas.xmlsoap.org/wsdl/soap/http")
public class ComplexService_ComplexPortTypeSoapPortImpl
    implements ComplexPortType
{

    public ComplexService_ComplexPortTypeSoapPortImpl() {
          System.out.println("nt ComplexPortTypeSoapPortImpl  Instentiated...");
    }

    /**
     *
     * @param struct
     * @return
     *     returns ws.BasicStruct
     */
    public BasicStruct echoComplexType(BasicStruct struct) {
        //replace with your impl here
          System.out.println("nt ComplexPortTypeSoapPortImpl  echoComplexType method called...Got struct  = "+struct);
        return struct;
    }

    /**
     *
     * @param integerInput
     * @return
     *     returns int
     */
    public int echoInt(int integerInput) {
          System.out.println("nt ComplexPortTypeSoapPortImpl  echoInt method called...Got integerInput  = "+integerInput);
        return integerInput;
    }

}

Step7). Now just run the ANT build again to build and deploy the WebService as following “ant -buildfile build.xml  deploy

ant deploy
Buildfile: build.xml

build-service:
    [mkdir] Created dir: /demos/TopDown/output/Complex_JAXWS_Ear
     [jwsc] JWS: processing module /ws/ComplexService_ComplexPortTypeSoapPortImpl
     [jwsc] Parsing source files
     [jwsc] Parsing source files
     [jwsc] 1 JWS files being processed for module /ws/ComplexService_ComplexPortTypeSoapPortImpl
     [jwsc] JWS: /demos/TopDown/ws/ComplexService_ComplexPortTypeSoapPortImpl.java Validated.
     [jwsc] Processing 1 JAX-WS web services...
     [jwsc] Compiling 1 source file to /tmp/_4ixn4v
     [jwsc] Building jar: /demos/TopDown/output/Complex_JAXWS_Ear/ws/ComplexService_ComplexPortTypeSoapPortImpl.war
     [jwsc] Created JWS deployment outputFile: /demos/TopDown/output/Complex_JAXWS_Ear/ws/ComplexService_ComplexPortTypeSoapPortImpl.war
     [jwsc] [EarFile] Application File : /demos/TopDown/output/Complex_JAXWS_Ear/META-INF/application.xml
[AntUtil.deleteDir] Deleting directory /tmp/_4ixn4v

deploy:
 [wldeploy] weblogic.Deployer -verbose -noexit -source /demos/TopDown/output/Complex_JAXWS_Ear -targets AdminServer -adminurl t3://localhost:7001 -user weblogic -password ******** -deploy
 [wldeploy] weblogic.Deployer invoked with options:  -verbose -noexit -source /demos/TopDown/output/Complex_JAXWS_Ear -targets AdminServer -adminurl t3://localhost:7001 -user weblogic -deploy
 [wldeploy] <May 4, 2011 3:55:10 PM IST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, Complex_JAXWS_Ear [archive: /demos/TopDown/output/Complex_JAXWS_Ear], to AdminServer .>
 [wldeploy] Task 0 initiated: [Deployer:149026]deploy application Complex_JAXWS_Ear on AdminServer.
 [wldeploy] Task 0 completed: [Deployer:149026]deploy application Complex_JAXWS_Ear on AdminServer.
 [wldeploy] Target state: deploy completed on Server AdminServer

 [wldeploy] Target Assignments:
 [wldeploy] + Complex_JAXWS_Ear  AdminServer

BUILD SUCCESSFUL
Total time: 5 seconds

Step8). Once the Service is deployed you can login to AdminConsole and then you can test it.

TestingWebService_FromConsol

.

.

Thanks

Jay SenSharma


UserName Token In JAXWS WebService

Hi,

Jay SenSharma

Jay SenSharma

Here is a Simple demonstration of using the UserName Token in WebLogic JAXWS WebServices.

Step1). Create a Directory  “F:DELETEAuthXML_UserName_Token” where we can place all our application sources…

Step2). Now we need to create our own UserNameToken.xml file. In order to do that Please create a Directory “policies” in the current directory “F:DELETEAuthXML_UserName_Token” and place the following “UsernameToken.xml

<?xml version="1.0"?>
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512">
<sp:SupportingTokens>
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssUsernameToken10/>
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SupportingTokens>
</wsp:Policy>
Step3). Now In the “F:DELETEAuthXML_UserName_Token” Directory Write your WebService “SecureHelloWorldImpl.java
package examples.webservices.security_jws;
import weblogic.jws.Policies;
import weblogic.jws.Policy;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;

@SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL, parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
@Policies({@Policy(uri="policy:UsernameToken.xml")})
@WebService(name="SecureHelloWorldPortType",serviceName="SecureHelloWorldService")
public class SecureHelloWorldImpl
{
@WebMethod()
public String sayHello(String s) {
return "JAXWS Service Says ... Hello " + s;
}
}
Step4). Now write the WebService Client in “F:DELETEAuthXML_UserName_Token” the Client name is “SecureHelloWorldClient.java
package client;
import examples.webservices.security_jws.client.*;
import java.util.*;
import javax.xml.ws.BindingProvider;
import weblogic.wsee.security.unt.ClientUNTCredentialProvider;
import weblogic.xml.crypto.wss.provider.CredentialProvider;
import weblogic.xml.crypto.wss.WSSecurityContext;
public class SecureHelloWorldClient {
public static void main(String[] args) throws Throwable {
String USERNAME = "weblogic";
String PASSWORD = "weblogic";
SecureHelloWorldService service=new SecureHelloWorldService();
SecureHelloWorldPortType port=service.getSecureHelloWorldPortTypePort();

//////////NOT TRY TO COMMENT OUT THE BELOW 8 Lines....Client Will Fail With Security Header Missing Exception
System.out.println("nnt-----1 Port: "+port);
BindingProvider bindingProvider = (BindingProvider) port;
Map<String,Object> rc = (Map<String,Object>)bindingProvider.getRequestContext();
List<CredentialProvider> credProviders = new ArrayList<CredentialProvider>();
credProviders.add(new ClientUNTCredentialProvider(USERNAME.getBytes(),PASSWORD.getBytes()));
rc.put(WSSecurityContext.CREDENTIAL_PROVIDER_LIST, credProviders);
rc.put(BindingProvider.USERNAME_PROPERTY, USERNAME);
rc.put(BindingProvider.PASSWORD_PROPERTY, PASSWORD);;
/////////////////////////////////////////////////////////////
String response = port.sayHello("World");
System.out.println("response = " + response);
}
}
Step 5). Now we need to write the “build.xml” so build the Service and the Client…
<project name="webservices-security_jws" default="all" basedir=".">
<!-- set global properties for this build -->
<property name="ws.file" value="SecureHelloWorldImpl" />
<property name="ear.dir" value="${basedir}/webservicesSecurityeEar" />
<property name="client.dir" value="${basedir}/webservicesSecurity_client" />
<property name="cert-dir" value="C:replicationcerts" />
<property name="wls.username" value="weblogic" />
<property name="wls.password" value="weblogic" />
<property name="wls.hostname" value="localhost" />
<property name="wls.port" value="7001" />
<property name="wls.server.name" value="AdminServer" />

<path id="client.class.path">
<pathelement path="${client.dir}"/>
<pathelement path="${java.class.path}"/>
</path>

<taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask" />
<taskdef name="clientgen" classname="weblogic.wsee.tools.anttasks.ClientGenTask" />
<target name="all" depends="clean,server,zip,deploy,client,run" />

<!-- Cleaning the WorkSpace -->
<target name="build" depends="clean,server,client" />
<target name="clean">
<delete dir="${ear.dir}"/>
<delete dir="${client.dir}"/>
</target>

<!-- To Build the WebService -->
<target name="server">
<mkdir dir="${ear.dir}"/>
<jwsc  srcdir="${basedir}"
       destdir="${ear.dir}"
       classpath="${java.class.path}"
       fork="true"
       keepGenerated="true"
       deprecation="${deprecation}"
       debug="true">
      <jws file="${ws.file}.java"  type="JAXWS"/>
</jwsc>
</target>

<!-- To add the Policy File Inside the WebService WAR file -->
<target name="zip">
<zip destfile="${ear.dir}/${ws.file}.war" update="true">
<zipfileset dir="." prefix="WEB-INF">
<include name="policies/*.xml"/>
</zipfileset>
</zip>
</target>

<!-- Deploy Application -->
<target name="deploy">
<wldeploy action="deploy"
          source="${ear.dir}"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${wls.server.name}" />
</target>

<!-- Redeploy Application -->
<target name="redeploy">
<wldeploy action="redeploy"
          source="${ear.dir}"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          failonerror="${failondeploy}"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${wls.server.name}" />
</target>

<!-- To Generate the Client Side Artifacts -->
<target name="client">
<mkdir dir="${client.dir}"/>
<clientgen type="JAXWS"
           wsdl="http://localhost:7001/SecureHelloWorldImpl/SecureHelloWorldService?WSDL"
           destDir="${client.dir}"
           classpath="${java.class.path}"
           packageName="examples.webservices.security_jws.client"/>
<javac  srcdir="${client.dir}" destdir="${client.dir}" classpath="${java.class.path}" includes="examples/webservices/security_jws/client/**/*.java"/>
<javac srcdir="${basedir}" destdir="${client.dir}" classpath="${java.class.path};${client.dir}" includes="SecureHelloWorldClient.java"/>
</target>

<!-- To Run the Client Program -->
<target name="run" >
<java fork="true" classname="client.SecureHelloWorldClient" failonerror="false" >
     <classpath refid="client.class.path"/>
     <arg line="weblogic weblogic" />
</java>
</target>
</project>

Step6). Now open a Command prompt and then run “setWLSEnv.cmd” or “setWLSEnv.sh”  and then just enter “ant” in the command prompt…
.
.
Thanks
Jay SenSharma


Fetching HttpHeaders inside JAXWS WebService

Hi,

Jay SenSharma

Jay SenSharma

If we want to display the HttpHeaders (NOT SOAPHeaders) inside our JAXWS webservice then we need to use   “javax.xml.ws.WebServiceContext” class provided as part of JAXWS APIs. Here is a Sample on How to use this API.

Step 1). Create a “src” directory inside Some Folder like: “C:JavaTestJAXWS_ClientHttpHeaders_ClientIP”

Step 2). Develope the WebService class “HelloWorldImpl.java” inside the “C:JavaTestJAXWS_ClientHttpHeaders_ClientIPsrcexampleswebserviceshello_world” Directory.

package examples.webservices.hello_world;
import javax.jws.*;
import javax.xml.ws.WebServiceContext;
import javax.annotation.Resource;
import javax.xml.ws.handler.MessageContext;
import java.util.*;
import javax.servlet.http.*;
import javax.xml.ws.handler.soap.*;

@WebService
public class HelloWorldImpl
{
@Resource
WebServiceContext wsCtxt;
@WebMethod
public String getClientIP()
{
MessageContext msgCtxt = wsCtxt.getMessageContext();
HttpServletRequest req = (HttpServletRequest)msgCtxt.get(MessageContext.SERVLET_REQUEST);
String clientIP = req.getRemoteAddr();
System.out.println("nnttClient's IP Address is : "+clientIP);
return "nt Your IP Address is : "+clientIP;
}
@WebMethod
public String sayHelloWorld(String message)
{
System.out.println("sayHelloWorld:" + message);
return "Here is the message: '" + message + "'";
}

@WebMethod
public String getHttpHeaders()
{
MessageContext context=wsCtxt.getMessageContext();
System.out.println("nnt Got MessageContext context = "+context);
Map map = (Map)context.get(MessageContext.HTTP_REQUEST_HEADERS);
String str="";

Set entries = map.entrySet();
Iterator iterator = entries.iterator();
while (iterator.hasNext())
{
Map.Entry entry = (Map.Entry)iterator.next();
str=str+"nHeader:" + entry.getKey() + " tValue: " + entry.getValue();
System.out.println("ntHeader:" + entry.getKey() + " : " + entry.getValue());
}

System.out.println("nnttClient's HTTP Headers are : "+str);
return "nt Your HTTP Headers are : "+str;
}
}

Step3). Provide the ANT “build.xml” file inside the “C:JavaTestJAXWS_ClientHttpHeaders_ClientIP”. Step4). Open a Command/Shell window and run the “setDomainEnv.sh/cmd” or “setWLSEnv.sh/cmd”.

Step4). Run the ANT…

Step5). Login to AdminConsole and Click on Test Client Page of deployed WebService…Execute the Method “getHttpHeaders” you will find the following SOAPResoponse:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getHttpHeadersResponse xmlns:ns2="http://hello_world.webservices.examples/">
<return>Your HTTP Headers are :
Header:Cookie Value: [PreviousWsdl1261036687257=VHJhbnNhY3Rpb25hbEltcGxTZXJ2aWNlfGh0dHA6Ly9sb2NhbGhvc3Q6NzAwMS9UcmFuc2FjdGlvbmFsSW1wbC9UcmFuc2FjdGlvbmFsSW1wbD9XU0RM; PreviousWsdl1261038900211=SGVsbG9Xb3JsZEltcGxTZXJ2aWNlfGh0dHA6Ly9sb2NhbGhvc3Q6NzAwMS9IZWxsb1dvcmxkSW1wbC9IZWxsb1dvcmxkSW1wbFNlcnZpY2U/V1NETA==; ADMINCONSOLESESSION=lNnpLqLNtCsxKGJFQhN517hmQ6c81lDYPF2QryGdcVbPzJfBLqct!-1472209373; JSESSIONID=LyG0LqLL849T3f2k4vLy2XlXKb3yWCDvy1P0XpVQtTvgyyTfLv9v!-1472209373]
Header:Host Value: [localhost:7001]
Header:Content-type Value: 
Header:Content-length Value: [183]
Header:Connection Value: [Keep-Alive]
Header:User-agent Value: [BEA WebLogic Server 10.3.0.0]
Header:Accept Value: 
Header:Soapaction Value: [""]</return>
</ns2:getHttpHeadersResponse>
</S:Body>
</S:Envelope>

.

.

Thanks

Jay SenSharma


Copyright © 2010-2012 Middleware Magic. All rights reserved. |