d0nMaTTi
asked on
How to send soadheader
I have webservice which use third-party's webservice component. This has method
getSimpl
I shoud send identifiation information (username,passwor,timestam p,checksum ) inside soapheader but I've no idea how to accomplish it .
Format of soapheader shoul be :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
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>
<wsse:Security
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">
<wsse:UsernameToken>
<wsse:Username>XXXXXXXXXXX X</wsse:Us ername>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">NNNNNNNN</wsse:Pas sword>
</wsse:UsernameToken>
</wsse:Security>
<cmn:timeStamp
xmlns:cmn="http://www.somebody.fi/XMLSchema/test_4.02.xsd">2010012714454 800+020000 0</cmn:tim eStamp>
<cmn:checkSum
xmlns:cmn="http://www.somebody.fi/XMLSchema/test_4.02.xsd">48D703C2E5250 EBB6C19701 F98435196< /cmn:check Sum>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<getSimpl
xmlns="http://www.somebydy.fi/test/">
<ns1:request xmlns:ns1="http://www.someboyd.fi/XMLSchema/test_Request_4.02.xsd">
<ns1:endUser>testtest</ns1 :endUser>
<ns1:personId>010100-123D< /ns1:perso nId>
<ns1:purpose>1</ns1:purpos e>
<ns1:searchName>Testi</ns1 :searchNam e>
<ns1:languageCode>FI</ns1: languageCo de>
<ns1:target>TAP1</ns1:targ et>
<ns1:model>SIMP1</ns1:mode l>
</ns1:request>
</getSiml>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
getSimp method has requesttype parameter which has enduser,personid .. fields and
the format of method is:
responseclass=getsimpl(req uesttypecl ass).
How to create this kind of soap header AND how to definat my own webmethon (which runs getsiml) vso that soapheader with identificatio-information and method-parameters will be passed on server????
Matti Niskasaari
getSimpl
I shoud send identifiation information (username,passwor,timestam
Format of soapheader shoul be :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
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>
<wsse:Security
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">
<wsse:UsernameToken>
<wsse:Username>XXXXXXXXXXX
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">NNNNNNNN</wsse:Pas
</wsse:UsernameToken>
</wsse:Security>
<cmn:timeStamp
xmlns:cmn="http://www.somebody.fi/XMLSchema/test_4.02.xsd">2010012714454
<cmn:checkSum
xmlns:cmn="http://www.somebody.fi/XMLSchema/test_4.02.xsd">48D703C2E5250
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<getSimpl
xmlns="http://www.somebydy.fi/test/">
<ns1:request xmlns:ns1="http://www.someboyd.fi/XMLSchema/test_Request_4.02.xsd">
<ns1:endUser>testtest</ns1
<ns1:personId>010100-123D<
<ns1:purpose>1</ns1:purpos
<ns1:searchName>Testi</ns1
<ns1:languageCode>FI</ns1:
<ns1:target>TAP1</ns1:targ
<ns1:model>SIMP1</ns1:mode
</ns1:request>
</getSiml>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
getSimp method has requesttype parameter which has enduser,personid .. fields and
the format of method is:
responseclass=getsimpl(req
How to create this kind of soap header AND how to definat my own webmethon (which runs getsiml) vso that soapheader with identificatio-information and method-parameters will be passed on server????
Matti Niskasaari
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Apparently .NET convert's reference-class from webservice and this class inherits namespace:
System.Web.Services.Protoc
When i changed it to Microsoft.Web.Services3.We
Now , when i want to soapheader with elements as follows:
UsernameToken user= new UsernameToken("myusername"
webservice.class on neededservice=new vebservice.class(),
neededservice.RequestSoapC
neededservice.RequestSoapC
//then I need to add also elements timeStamp and checkSum//
string strTimeStamp="201002021125
stirng strchecSum="44545adsfgafaf
neededservice.RequestSoapC
neededservice.RequestSoapC
myanswer=neededservice.get
Is this the way to create additional elements to soapheader which client (my program) sends to server?
ASKER
Problem solved.
When i add elements this way:
proxy.RequestSoapContext.S ecurity.Mu stUndersta nd = true;
proxy.RequestSoapContext.S ecurity.To kens.Add(u ser);
proxy.RequestSoapContext.S ecurity.El ements.Add (new Microsoft.Web.Services3.Se curity.Mes sageSignat ure(user)) ;
user.AnyElements.Add(xmlel ementtimes tamp);
user.AnyElements.Add(xmlel ementcheck sum);
server founds all needed elements from soapheader.
When i add elements this way:
proxy.RequestSoapContext.S
proxy.RequestSoapContext.S
proxy.RequestSoapContext.S
user.AnyElements.Add(xmlel
user.AnyElements.Add(xmlel
server founds all needed elements from soapheader.
ASKER
the link of example tell part of my problem. It was a good example from usernametoken but it didn't solve whole problem
ASKER
doesn't work on vs 2008 (framework 3.5) because of method: SetClientCredential , I can't find it.
There is a ClientCredentials property which is readonly.
I've added webrefence named ThidParty and that has class consumer_4_02
so if I've understood right the links example
(ObjectService.ServiceWse swe = new ObjectService.ServiceWse()
it would go: Thirdpary.consumer_4_02 cons = new ThirdParty.consumer_4_02()
cons has ClientCredentials property but not SetClientCredential
I'm doubtful that i've understood something wrong.