It would be something like:

Element el = document.createElementNS(_theYahooURL, "onBehalfOfPassword");

Dan




On Jul 3, 2008, at 1:40 PM, nmt999 wrote:


Dan

I'm not sure how to do that. Can you show me how to do that for one of the
elments

nmt


dkulp wrote:


That's the problem:

       Element passwordElement =
document.createElement("onBehalfOfPassword");

You aren't namespace qualifying those elements.    You need to create
the elements using the namespace versions and specify the proper
namespaces and such.

Dan



On Jul 3, 2008, at 1:28 PM, nmt999 wrote:


Dan

Security headers are added in WSS4JOutInterceptor which is in the
createAccountService method. Headers are added in handleMessage() of
my
outboundinterceptor that extends AbstracSoapInterceptor which is
given below

  private static AccountService createAccountService(String
aServiceURL)
  {
      AccountService ret = null;

      JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
      factory.getInInterceptors().add(new LoggingInInterceptor());
      factory.getOutInterceptors().add(new LoggingOutInterceptor());
      factory.setServiceClass(AccountService.class);
      factory.setAddress(aServiceURL);
      factory.setBus(BusFactory.getDefaultBus());

      ret = (AccountService) factory.create();
      Client client = factory.getClientFactoryBean().getClient();
      Endpoint endpoint = client.getEndpoint();

      // Add any inbound interceptors that are needed
      InboundInterceptor inboundInterceptor = new
InboundInterceptor();
      endpoint.getInInterceptors().add(inboundInterceptor);

      // Add any outbound interceptors that are needed
      // Need to add the corresponding SAAJ interceptor if you are
using
WSS
      // interceptor
      Map<String,Object> props = new HashMap<String,Object>();
      props.put(WSHandlerConstants.PW_CALLBACK_CLASS,
ClientPasswordHandler.class.getName());

      WSS4JOutInterceptor wss4jOutInterceptor = new
WSS4JOutInterceptor(props);
      wss4jOutInterceptor.setProperty(WSHandlerConstants.ACTION,
WSHandlerConstants.USERNAME_TOKEN);
      wss4jOutInterceptor.setProperty(WSHandlerConstants.USER,
_theUsername);

wss4jOutInterceptor.setProperty(WSHandlerConstants.PASSWORD_TYPE,
WSConstants.PW_TEXT);

      endpoint.getOutInterceptors().add(wss4jOutInterceptor);
      endpoint.getOutInterceptors().add(new SAAJOutInterceptor());

      OutboundInterceptor outboundInterceptor = new
OutboundInterceptor(_theLicense, _theMasterAccountID, null, null,
null,
SANDBOX_ACCOUNTSERVICE_NAME);
      endpoint.getOutInterceptors().add(outboundInterceptor);

      return ret;
  }


Adding headers
=========

constructor

      super(Phase.WRITE);

addBefore ("org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor")

in handle message

       // Add SOAP headers to be sent
      Document document = DOMUtils.createDocument();
      List<Header> headers = aSoapMessage.getHeaders();

      SoapHeader masterAccountIdHeader = null;
      Element masterAccountIDElement =
document.createElement("masterAccountID");
      masterAccountIDElement.setTextContent(_theMasterAccountId);
      masterAccountIdHeader = new SoapHeader(new QName(_theYahooURL,
_theServiceName), masterAccountIDElement);
      headers.add(masterAccountIdHeader);

      SoapHeader licenseHeader = null;
      Element licenseElement = document.createElement("license");
      licenseElement.setTextContent(_theLicense);
      licenseHeader = new SoapHeader(new QName(_theYahooURL,
_theServiceName), licenseElement);
      headers.add(licenseHeader);

      SoapHeader accountIDHeader = null;
Element accountIDElement = document.createElement("accountID");
      accountIDElement.setTextContent(_theAccountId);
      accountIDHeader = new SoapHeader(new QName(_theYahooURL,
_theServiceName), accountIDElement);
      headers.add(accountIDHeader);

      SoapHeader usernameHeader = null;
      Element usernameElement =
document.createElement("onBehalfOfUsername");
      usernameElement.setTextContent(_theUsername);
      usernameHeader = new SoapHeader(new QName(_theYahooURL,
_theServiceName), usernameElement);
      headers.add(usernameHeader);

      SoapHeader passwordHeader = null;
      Element passwordElement =
document.createElement("onBehalfOfPassword");
      passwordElement.setTextContent(_thePassword);
      passwordHeader = new SoapHeader(new QName(_theYahooURL,
_theServiceName), passwordElement);
      headers.add(passwordHeader);




dkulp wrote:


In "Case 2", how are you setting the headers:
 <masterAccountID>11111111</masterAccountID>
 <license>999999999</license>
 <onBehalfOfUsername />
 <onBehalfOfPassword />

Without the -exsh true, they wouldn't be method parameters so you are
setting them some other way.  SAAJ handler?   Through the request
context? etc...   I would need to see that code.

Dan



On Jul 3, 2008, at 10:22 AM, nmt999 wrote:


In my client developement using cxf to talk to yahoo searchmarketing
services
(http://searchmarketing.yahoo.com/developer/docs/V4/wsdl/V4/AccountService.wsdl
),
I have two different implementations. I have them below. Case 1
works but
not Case 2. How can I make the Case 2 work.

Does wsdl2java command when used with and without -exsh option
make a
difference for the client when making requests to a webservice. Does
the two
soap requests sent any different?

Case 1:
=====
wsdl2java used witn -exsh true option
wsdl2java command used: wsdl2java -client -exsh true -p
com.test.accountservice AccountService.wsdl

Following request was generated and  sent successfully:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/">
<soap:Header>
        <ns2:onBehalfOfUsername
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:ns3="http://schemas.xmlsoap.org/ws/2002/07/secext";
xmlns:ns2="http://marketing.ews.yahooapis.com/V4"; xsi:nil="true" />
        <ns2:onBehalfOfPassword
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:ns3="http://schemas.xmlsoap.org/ws/2002/07/secext";
xmlns:ns2="http://marketing.ews.yahooapis.com/V4"; xsi:nil="true" />
        <ns2:masterAccountID
xmlns:ns3="http://schemas.xmlsoap.org/ws/2002/07/secext";
xmlns:ns2="http://marketing.ews.yahooapis.com/V4";>11111111</
ns2:masterAccountID>
        <ns2:license xmlns:ns3="http://schemas.xmlsoap.org/ws/2002/07/secext
"
xmlns:ns2="http://marketing.ews.yahooapis.com/V4";>9999999</
ns2:license>
        <ns3:Security xmlns:ns3="http://schemas.xmlsoap.org/ws/2002/07/
secext"
xmlns:ns2="http://marketing.ews.yahooapis.com/V4";>
                <UsernameToken>
                        <Username>username</Username>
                        <Password>password</Password>
                </UsernameToken>
        </ns3:Security>
</soap:Header>
<soap:Body>
 <ns2:getAccountStatus
xmlns:ns2="http://marketing.ews.yahooapis.com/V4
"
xmlns:ns3="http://schemas.xmlsoap.org/ws/2002/07/secext";>
     <ns2:accountID>222222222</ns2:accountID>
 </ns2:getAccountStatus>
</soap:Body>
</soap:Envelope>

Response received successfully

Case 2:
=====
wsdl2java used without the exsh option
wsdl2java command used: wsdl2java -client -p com.test.accountservice
AccountService.wsdl

Following request was generated and sent successfully:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/">
<soap:Header>
<wsse:Security
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
"
soap:mustUnderstand="1">
 <wsse:UsernameToken
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
"
wsu:Id="UsernameToken-24164377">
     <wsse:Username
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
">username</wsse:Username>
     <wsse:Password
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
"
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText
">password</wsse:Password>
 </wsse:UsernameToken></wsse:Security>
 <masterAccountID>11111111</masterAccountID>
 <license>999999999</license>
 <onBehalfOfUsername />
 <onBehalfOfPassword />
 </soap:Header>
<soap:Body>
 <ns2:getAccountStatus
xmlns:ns2="http://marketing.ews.yahooapis.com/V4
"
xmlns:ns3="http://schemas.xmlsoap.org/ws/2002/07/secext";>
     <ns2:accountID>222222222</ns2:accountID>
 </ns2:getAccountStatus>
</soap:Body>
</soap:Envelope>

Response received has soap fault as below:
        <soap:Fault><faultcode>soap:Server</faultcode>
        <faultstring>An internal error has occurred.</faultstring>
                <detail>
<yns:ApiFault xmlns:yns="http://marketing.ews.yahooapis.com/ V4">
                                <yns:code
xmlns:yns="http://marketing.ews.yahooapis.com/V4";>E1002</yns:code>
                                <yns:message 
xmlns:yns="http://marketing.ews.yahooapis.com/
V4">An
internal error has occurred.</yns:message>
                        </yns:ApiFault>
        </detail>
        </soap:Fault>


Regards
nmt
--
View this message in context:
http://www.nabble.com/Does-wsdl2java-command-when-used-with-and-without--exsh-option-make-a-difference-for-the-client-when-making-requests-to-a-webservice-tp18260156p18260156.html
Sent from the cxf-user mailing list archive at Nabble.com.


---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog







--
View this message in context:
http://www.nabble.com/Does-wsdl2java-command-when-used-with-and-without--exsh-option-make-a-difference-for-the-client-when-making-requests-to-a-webservice-tp18260156p18264430.html
Sent from the cxf-user mailing list archive at Nabble.com.


---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog







--
View this message in context: 
http://www.nabble.com/Does-wsdl2java-command-when-used-with-and-without--exsh-option-make-a-difference-for-the-client-when-making-requests-to-a-webservice-tp18260156p18264746.html
Sent from the cxf-user mailing list archive at Nabble.com.


---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog




Reply via email to