Build using latest code in SVN, then turn on trace as described in last 
comment of JIRA http://issues.apache.org/jira/browse/AXISCPP-100

Nadir Amra


"Golikov, Vassili" <vassili.goli...@credit-suisse.com> wrote on 02/09/2009 
09:32:46 AM:

> [image removed] 
> 
> RE: How to get a value from SOAP header using Axis C++?
> 
> Golikov, Vassili 
> 
> to:
> 
> Apache AXIS C User List
> 
> 02/09/2009 09:35 AM
> 
> Please respond to "Apache AXIS C User List"
> 
> I tried to get data from the body but I did not succeed. I modified 
> a piece of code generated by Axis to have
> 
> 
>                 if(AXIS_SUCCESS == m_pCall->checkMessage("LoginReturn", 
"
> http://www.informatica.com/wsh";))
>                 {
>                         std::string lsessionId = 
> m_pCall->getElementAsString( "SessionId", "
http://www.informatica.com/wsh";);
>                 }
> 
> So  m_pCall->checkMessage("LoginReturn", "http://www.informatica.com/wsh
> ")) works fine but the method call 
> 
> getElementAsString with an exception. I also tried 
> getElementAsString( "SessionId", 0). I did not work either.
> 
> Do you have any ideas?
> 
> From: McCullough, Ryan [mailto:rmccullo...@rightnow.com] 
> Sent: Friday, February 06, 2009 5:46 PM
> To: Apache AXIS C User List
> Subject: RE: How to get a value from SOAP header using Axis C++?

> After implementing that code into axis, you could get the session idlike 
this:
> /* Example Soap 
> <soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/
> " xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://
> www.w3.org/2001/XMLSchema-instance">
>    <soapenv:Header>
>       <ns1:Context soapenv:actor="" soapenv:mustUnderstand="0" 
xmlns:ns1="
> http://www.informatica.com/wsh";>
>          <SessionId>1d2b79bbe22efa2011f4cf3a9db</SessionId>
>       </ns1:Context>
>    </soapenv:Header>
>    <soapenv:Body>
>       <LoginReturn xmlns="http://www.informatica.com/wsh
> ">1d2b79bbe22efa2011f4cf3a9db</LoginReturn>
>    </soapenv:Body>
> </soapenv:Envelope>
> */
> IHeaderBlock* Header = 
YourStub->getCall()->getDeSerHeaderBlock("Context", "
> http://www.informatica.com/wsh";);
> if (Header != NULL)
> {
>     for (int i=1; i <= Header->getNoOfChildren(); i++)
>     {
>         BasicNode* t_ElementNode = Header->getChild(i);
>         if (t_ElementNode != NULL && strcmp
> (t_ElementNode->getLocalName(),"SessionId") == 0)
>         {
>             BasicNode* t_CharacterNode = t_ElementNode->getChild(1);
>             if (t_CharacterNode != NULL)
>             {
>                 printf("Session ID: %s\n", t_CharacterNode->getValue());
>             }
>             break;
>         }
>     }
> }
> 
> I do have a question though, it looks like the session id is in the 
> soap body. Why couldn?t you parse it out of ?LoginReturn??
> 
> For creating the soap header of your request, you should look at 
> ?Stub::createSOAPHeaderBlock()?. There is decent documentation for 
> it as well. From the axis\include\axis\client\Stub.hpp file:
>   /**
>     * Create and add a SOAP header block to the Stub.
>     * 
>     * This will create a header block that would look like the following 
when 
>     * serialized:
>     * \verbatim
> <th:TestHeader xmlns:th="http://ws.apache.org/axisCppTest/";>
> </th:TestHeader>
> \endverbatim
>     *
>     * User must use the IHeaderBlock pointer returned and fill in 
> the header structure.
>     * e.g. To make the SOAP header look like
>     * \verbatim
> <SOAP-ENV:Header>
>     <th:TestHeader xmlns:th="http://ws.apache.org/axisCppTest/";>
>         <Credentials>
>             <username>Test User</username>
>             <password>Test Password</password>
>         </Credentials>
>     </th:TestHeader>
> </SOAP-ENV:Header>
> \endverbatim
>     * the following code segment could be used
>     * <code>
>     * 
>     * IHeaderBlock *phb = ws.createSOAPHeaderBlock("TestHeader", 
>     *                                   "
http://ws.apache.org/axisCppTest/";,
>     *                                   "th");
>     * 
>     * 
>     *  //create parent node
>     * 
>     *  BasicNode *parentNode = phb->createChild(ELEMENT_NODE);
>     * 
>     *  parentNode->setLocalName("Credentials");
>     * 
>     * 
>     *  //create child node
>     * 
>     *  BasicNode *childNode = phb->createChild(ELEMENT_NODE);
>     * 
>     *  childNode->setLocalName("username");
>     * 
>     * 
>     *  //create char node for value
>     * 
>     *  BasicNode *valueNode = phb->createChild(CHARACTER_NODE);
>     * 
>     *  valueNode->setValue("Test User");
>     *
>     * 
>     *  //buld node tree
>     * 
>     *  childNode->addChild(valueNode);
>     * 
>     *  parentNode->addChild(childNode);
>     * 
>     *
>     *  //add another node set
>     * 
>     *  childNode = phb->createChild(ELEMENT_NODE);
>     * 
>     *  childNode->setLocalName("password");
>     * 
>     *
>     *  valueNode = phb->createChild(CHARACTER_NODE);
>     * 
>     *  valueNode->setValue("Test Password");
>     * 
>     *
>     *  childNode->addChild(valueNode);
>     * 
>     *  parentNode->addChild(childNode);
>     * 
>     *
>     *  phb->addChild(parentNode);
>     * </code>
>     *
>     * @param pachLocalName Local tag name of the SOAP header. e.g. 
TestHeader
>     * @param pachPrefix Prefix to be used in XML represenation of SOAP 
header
>     *                   e.g. th
>     * @param pachUri Namespace URI to be used in SOAP header.
>                      e.g http://ws.apache.org/axisCppTestHeader/
>     *
>     * @return Pointer to the creater SOAP header block.
>     */
>     IHeaderBlock* AXISCALL createSOAPHeaderBlock(AxisChar * 
pachLocalName,
>                                                  AxisChar * pachUri, 
>                                                  AxisChar * pachPrefix);
> 
> From: McCullough, Ryan [mailto:rmccullo...@rightnow.com] 
> Sent: Friday, February 06, 2009 3:27 PM
> To: Apache AXIS C User List
> Subject: RE: How to get a value from SOAP header using Axis C++?
> 
> We had a similar issue. We resolved it by modifying the source code 
> and compiling our own Axis binaries.
> 
> Add the following
> axis\include\axis\client\Call.hpp:
>     /**
>      * Returns the DeSerialized response header.
>      */
>     IHeaderBlock* getDeSerHeaderBlock(const AxisChar * pName, const 
> AxisChar * pNamespace);
> 
> axis\src\engine\client\Call.cpp
> IHeaderBlock* Call::getDeSerHeaderBlock(const AxisChar * pName, 
> const AxisChar * pNamespace)
> {
>     if (m_pIWSDZ != NULL) {
>         return m_pIWSDZ->getHeaderBlock(pName, pNamespace, false);
>     } else {
>         return NULL;
>     }
> }
> 
> axis\src\soap\SoapDeSerializer.h
>     IHeaderBlock* getHeaderBlock(const AxisChar* pName, const 
> AxisChar* pNamespace, bool bRemoveOrNot);
> 
> axis\src\soap\SoapDeSerializer.cpp
> /*
>  * Header block parsing should be done differently for different 
> SOAP versions.
>  * Since the Header blocks may be requested in a different order 
> than it is in 
>  * the SOAP stream there must be a mechanism to manage the 
> situation. Possibly 
>  * to re-parse the stream part which has unused header blocks.
>  */
> IHeaderBlock *SoapDeSerializer::
> getHeaderBlock (const AxisChar * pName, const AxisChar * pNamespace,
> bool bRemoveOrNot)
> {
>     // if no <Header> element there can be no Header blocks 
>     if (!m_pHeader)
>         return NULL; 
> 
>     return m_pHeader->getHeaderBlock (pName, pNamespace, bRemoveOrNot);
> }
> 
> -Ryan
> 
> From: Golikov, Vassili [mailto:vassili.goli...@credit-suisse.com] 
> Sent: Friday, February 06, 2009 3:05 PM
> To: Apache AXIS C User List
> Subject: RE: How to get a value from SOAP header using Axis C++?
> 
> C++.
> 
> This is actual response from PowerCenter:
> 
> 
> <soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/";
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://
> www.w3.org/2001/XMLSchema-instance">
>    <soapenv:Header>
>       <ns1:Context soapenv:actor="" soapenv:mustUnderstand="0" 
xmlns:ns1="
> http://www.informatica.com/wsh";>
>          <SessionId>1d2b79bbe22efa2011f4cf3a9db</SessionId>
>       </ns1:Context>
>    </soapenv:Header>
>    <soapenv:Body>
>       <LoginReturn xmlns="http://www.informatica.com/wsh";
> >1d2b79bbe22efa2011f4cf3a9db</LoginReturn>
>    </soapenv:Body>
> </soapenv:Envelope>
> 
> Session ID is mentioned in two places. In the header: 
> 
> <SessionId>1d2b79bbe22efa2011f4cf3a9db</SessionId> and in the body 
> <LoginReturn xmlns="http://www.informatica.com/wsh";
> >1d2b79bbe22efa2011f4cf3a9db</LoginReturn>
> Could you tell me how to get that Session Id and re-submit in another 
header?
> 
> E.g.
> 
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:
> xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://
> www.w3.org/2001/XMLSchema">
>    <soap:Header>
>       <ns0:Context xmlns:ns0="http://www.informatica.com/wsh";>
>          <SessionId>[string]</SessionId>
>       </ns0:Context>
>    </soap:Header>
>    <soap:Body>
>       <ns0:GetWorkflowLog xmlns:ns0="http://www.informatica.com/wsh";>
>          <DIServiceInfo>
>             <DomainName>[string]</DomainName>
>             <ServiceName>[string]</ServiceName>
>          </DIServiceInfo>
>          <FolderName>[string]</FolderName>
>          <WorkflowName>[string]</WorkflowName>
>          <WorkflowRunId>[int]</WorkflowRunId>
>          <WorkflowRunInstanceName>[string]</WorkflowRunInstanceName>
>          <Timeout>[int]</Timeout>
>       </ns0:GetWorkflowLog>
>    </soap:Body>
> </soap:Envelope>
> 
> 
> Session ID should be here 
> 
>       <ns0:Context xmlns:ns0="http://www.informatica.com/wsh";>
>          <SessionId>[string]</SessionId>
>       </ns0:Context>
> 
> 
> 
> From: McCullough, Ryan [mailto:rmccullo...@rightnow.com] 
> Sent: Friday, February 06, 2009 4:59 PM
> To: Apache AXIS C User List
> Subject: RE: How to get a value from SOAP header using Axis C++?
> Are you using Axis2/c? or Axis c++?
> 
> From: Golikov, Vassili [mailto:vassili.goli...@credit-suisse.com] 
> Sent: Friday, February 06, 2009 2:50 PM
> To: axis-c-user@ws.apache.org
> Subject: How to get a value from SOAP header using Axis C++?
> 
> My apps server needs to talk to Informatica WS. It sends a session 
> ID in the header which should be retrieved and used in all their 
> requests. How can I get this value from a SOAP header?
> Vassilli Golikov 
> Equity Derivatives IT
> Credit Suisse Securities (USA) LLC
> One Madison Avenue
> 10th Floor
> New York, NY 10010
> 212-325-8972 (Tel)
> Email: vassili.goli...@credit-suisse.com 
> 
> 
==============================================================================
> Please access the attached hyperlink for an important electronic 
> communications disclaimer: 
> 
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> 
==============================================================================
> 
==============================================================================
> Please access the attached hyperlink for an important electronic 
> communications disclaimer: 
> 
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> 
==============================================================================
> 
==============================================================================
> Please access the attached hyperlink for an important electronic 
> communications disclaimer: 
> 
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> 
==============================================================================

Reply via email to