RE: How to get a value from SOAP header using Axis C++?
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" 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 > http://schemas.xmlsoap.org/soap/envelope/ > " xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http:// > www.w3.org/2001/XMLSchema-instance"> > > http://www.informatica.com/wsh";> > 1d2b79bbe22efa2011f4cf3a9db > > > > http://www.informatica.com/wsh > ">1d2b79bbe22efa2011f4cf3a9db > > > */ > 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 > http://ws.apache.org/axisCppTest/";> > > \endverbatim > * > * User must use the IHeaderBlock pointer returned and fill in > the header structure. > * e.g. To make the SOAP header look like > * \verbatim > > http://ws.apache.org/axisCppTest/";> > > Test User > Test Password > > > > \endverbatim > * the following code segment could be used > * > * > * 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); > * > * > * /
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 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: http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> http://www.informatica.com/wsh";> 1d2b79bbe22efa2011f4cf3a9db http://www.informatica.com/wsh";>1d2b79bbe22efa2011f4cf3a9db Session ID is mentioned in two places. In the header: 1d2b79bbe22efa2011f4cf3a9db and in the body http://www.informatica.com/wsh";>1d2b79bbe22efa2011f4cf3a9db Could you tell me how to get that Session Id and re-submit in another header? E.g. http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema";> http://www.informatica.com/wsh";> [string] http://www.informatica.com/wsh";> [string] [string] [string] [string] [int] [string] [int] Session ID should be here http://www.informatica.com/wsh";> [string] 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 ==
RE: How to get a value from SOAP header using Axis C++?
C++. This is actual response from PowerCenter: http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> http://www.informatica.com/wsh";> 1d2b79bbe22efa2011f4cf3a9db http://www.informatica.com/wsh";>1d2b79bbe22efa2011f4cf3a9db Session ID is mentioned in two places. In the header: 1d2b79bbe22efa2011f4cf3a9db and in the body http://www.informatica.com/wsh";>1d2b79bbe22efa2011f4cf3a9db Could you tell me how to get that Session Id and re-submit in another header? E.g. http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema";> http://www.informatica.com/wsh";> [string] http://www.informatica.com/wsh";> [string] [string] [string] [string] [int] [string] [int] Session ID should be here http://www.informatica.com/wsh";> [string] 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 ==
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 ==