You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Greg Pedder <gp...@tampabay.rr.com> on 2004/01/12 05:43:39 UTC

SOAP Help Building Request With Nested Tags

I have been struggling with Apache SOAP to try and build a request. Specifically, I don't understand how to embed these elements into the Header and Body sections. More specifically, how to do this nested tags. 
Thanks for any advice you can provide.

Below, is a sample of the request I need to send to the server. 


<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<ContinueHeader xmlns="http://www.openuri.org/2002/04/soap/conversation/">
<uniqueID>111111111111111</uniqueID>
</ContinueHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<subscribe xmlns="http://xxxx/xxxx/xxxx/service">
<comHdr>
<WSCredentials>
<UserName>xxxxxxx</UserName>
<Password>xxxxxxxx</Password>
</WSCredentials>
</comHdr>
</subscribe>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


I can add the <UserName>xxxxxxx</UserName> <Password>xxxxxxxx</Password> to the body of the request using:

Vector parms = new Vector();
parms.addElement(new Parameter("UserName", String.class, username, null));
parms.addElement(new Parameter("Token", String.class, password, null));
call.setParams(parms);

I just don't know how to add those tags within the <comHdr> and <WSCredentials> tags. 

Re: SOAP Help Building Request With Nested Tags

Posted by Scott Nichol <sn...@scottnichol.com>.
In your example, "subscribe" is the method being called.  Because its element has exactly one child element, there is exactly one parameter to the method, something called "comHdr", which is an XML complexType.  You would model this in your Java code as a class.

public class _ComHdr {
    public _WSCredentials WSCredentials = new _WSCredentials();
}

public class _WSCredentials {
    public string UserName;
    public string Password;
}

_ComHdr ch = new _ComHdr();
ch.WSCredentials.UserName = "xxxxx";
ch.WSCredentials.Password = "yyyyy";

// Here you must map BeanSerializer as [de-]serializer for _WSCredentials, _ComHdr classes,
// but I will leave it to you to look at, say, the AddressBook samples to see how this is done

Vector parms = new Vector();
parms.addElement(new Parameter("comHdr", _ComHdr.class, ch, null));
call.setParams(parms);

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Greg Pedder" <gp...@tampabay.rr.com>
To: <so...@ws.apache.org>
Sent: Sunday, January 11, 2004 11:43 PM
Subject: SOAP Help Building Request With Nested Tags


I have been struggling with Apache SOAP to try and build a request. Specifically, I don't understand how to embed these elements into the Header and Body sections. More specifically, how to do this nested tags. 
Thanks for any advice you can provide.

Below, is a sample of the request I need to send to the server. 


<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<ContinueHeader xmlns="http://www.openuri.org/2002/04/soap/conversation/">
<uniqueID>111111111111111</uniqueID>
</ContinueHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<subscribe xmlns="http://xxxx/xxxx/xxxx/service">
<comHdr>
<WSCredentials>
<UserName>xxxxxxx</UserName>
<Password>xxxxxxxx</Password>
</WSCredentials>
</comHdr>
</subscribe>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


I can add the <UserName>xxxxxxx</UserName> <Password>xxxxxxxx</Password> to the body of the request using:

Vector parms = new Vector();
parms.addElement(new Parameter("UserName", String.class, username, null));
parms.addElement(new Parameter("Token", String.class, password, null));
call.setParams(parms);

I just don't know how to add those tags within the <comHdr> and <WSCredentials> tags. 


Re: SOAP Help Building Request With Nested Tags

Posted by Scott Nichol <sn...@scottnichol.com>.
The BeanSerializer names elements based on the names of bean properties.  Therefore, the WSCredentials property of ComHdr would be serialized as <WSCredentials>....</WSCredentials>, and the UserName property of WSCredentials would be serialized as <UserName>.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Greg Pedder" <gp...@tampabay.rr.com>
To: <so...@ws.apache.org>
Sent: Tuesday, January 13, 2004 7:13 AM
Subject: Re: SOAP Help Building Request With Nested Tags


Scott

Thanks alot for your response. 

Let me ask this. I still don't understand how the tags <> <> are created for WSCredentials class. 
Do they automatically get created based on the class name  and members or would I need to do something
like this within the WSCredentials class?


public class _WSCredentials {

    public string UserName 
    public string Password;

    public void setUsername( String username ) {
              UserName = "<Username>" +username +"</Username>;
   }

   public void setPassword( String password ) {
              UserName = "<Password>" +password +"</Password>;
   }


}

Thanks..


  ----- Original Message ----- 
  From: Greg Pedder 
  To: soap-user@ws.apache.org 
  Sent: Sunday, January 11, 2004 11:43 PM
  Subject: SOAP Help Building Request With Nested Tags


  I have been struggling with Apache SOAP to try and build a request. Specifically, I don't understand how to embed these elements into the Header and Body sections. More specifically, how to do this nested tags. 
  Thanks for any advice you can provide.

  Below, is a sample of the request I need to send to the server. 


  <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Header>
  <ContinueHeader xmlns="http://www.openuri.org/2002/04/soap/conversation/">
  <uniqueID>111111111111111</uniqueID>
  </ContinueHeader>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
  <subscribe xmlns="http://xxxx/xxxx/xxxx/service">
  <comHdr>
  <WSCredentials>
  <UserName>xxxxxxx</UserName>
  <Password>xxxxxxxx</Password>
  </WSCredentials>
  </comHdr>
  </subscribe>
  </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>


  I can add the <UserName>xxxxxxx</UserName> <Password>xxxxxxxx</Password> to the body of the request using:

  Vector parms = new Vector();
  parms.addElement(new Parameter("UserName", String.class, username, null));
  parms.addElement(new Parameter("Token", String.class, password, null));
  call.setParams(parms);

  I just don't know how to add those tags within the <comHdr> and <WSCredentials> tags. 


Re: SOAP Help Building Request With Nested Tags

Posted by Greg Pedder <gp...@tampabay.rr.com>.
Scott

Thanks alot for your response. 

Let me ask this. I still don't understand how the tags <> <> are created for WSCredentials class. 
Do they automatically get created based on the class name  and members or would I need to do something
like this within the WSCredentials class?


public class _WSCredentials {

    public string UserName 
    public string Password;

    public void setUsername( String username ) {
              UserName = "<Username>" +username +"</Username>;
   }

   public void setPassword( String password ) {
              UserName = "<Password>" +password +"</Password>;
   }


}

Thanks..


  ----- Original Message ----- 
  From: Greg Pedder 
  To: soap-user@ws.apache.org 
  Sent: Sunday, January 11, 2004 11:43 PM
  Subject: SOAP Help Building Request With Nested Tags


  I have been struggling with Apache SOAP to try and build a request. Specifically, I don't understand how to embed these elements into the Header and Body sections. More specifically, how to do this nested tags. 
  Thanks for any advice you can provide.

  Below, is a sample of the request I need to send to the server. 


  <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Header>
  <ContinueHeader xmlns="http://www.openuri.org/2002/04/soap/conversation/">
  <uniqueID>111111111111111</uniqueID>
  </ContinueHeader>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
  <subscribe xmlns="http://xxxx/xxxx/xxxx/service">
  <comHdr>
  <WSCredentials>
  <UserName>xxxxxxx</UserName>
  <Password>xxxxxxxx</Password>
  </WSCredentials>
  </comHdr>
  </subscribe>
  </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>


  I can add the <UserName>xxxxxxx</UserName> <Password>xxxxxxxx</Password> to the body of the request using:

  Vector parms = new Vector();
  parms.addElement(new Parameter("UserName", String.class, username, null));
  parms.addElement(new Parameter("Token", String.class, password, null));
  call.setParams(parms);

  I just don't know how to add those tags within the <comHdr> and <WSCredentials> tags.