views:

239

answers:

1

I'm pretty new to SOAP so go easy on me. I'm trying to setup a SOAP service that accepts the following header format:

<soap:Header>
   <wsse:Security>
      <wsse:UsernameToken wsu:Id='SecurityToken-securityToken'>
         <wsse:Username>Username</wsse:Username>
         <wsse:Password>Password</wsse:Password>
         <wsu:Created>Timestamp</wsu:Created>
      </wsse:UsernameToken>
   </wsse:Security>
</soap:Header>

The application I'm incorporating this service into is an ASP.NET 3.5 web application and I've already setup a SOAP endpoint using WCF. I've setup a basic service to make sure the WCF works and it works fine (disregarding the header). I heard that the above format follows WS-Security so I added WSHttpBinding in the web.config:

<service name="Nexternal.Service.XMLTools.VNService"
         behaviorConfiguration="VNServiceBehavior">
  <!--The first endpoint would be picked up from the confirg
  this shows how the config can be overriden with the service host-->
  <endpoint address=""
            binding="wsHttpBinding"
            contract="Nexternal.Service.XMLTools.IVNService"/>
</service>

I downloaded a test harness (soapUI) and pasted in a test message with the above header and it came back with a 400 Bad Request error.

...for what it's worth, I'm running Visual Studio 2008 using IIS7.

I feel like I'm going in circles so any help would be awesome. Thanks in advance.

+1  A: 

Figured it out. I was able to customize what was generated in the WSDL using MessageContracts (http://msdn.microsoft.com/en-us/library/ms730255.aspx). This allowed me to specify the format of the header. For each node that contained child nodes I created a class to represent that node and used .NET's serializing tools (e.g. XmlElementAttribute, XmlArrayAttribute, etc.) to specify how this should be reflected in the generated WSDL. DataContract could also be used although from my understanding DataContract was just for basic formats and don't allow you to really dive into how it's formatted.

Hope this helps anyone having similar issues.

If anyone that knows more about SOAP finds a flaw please let me know. Input is greatly appreciated.

Adam