Can you send me the code - thnx  
Author Message
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

Hi, Im using a custom UsernameTokenManager in WSE 3.0 but it always authenticates when it should'nt.
I'm missing something but don't know what.

 

 


my Web Service code is:


using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = " http://www.hide-link.com/ ")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Services3.Policy("usernameTokenSecurity")]
public class Service : System.Web.Services.WebService
{
    public Service () {

        //Uncomment the following line if using designed components
        //InitializeComponent();
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
   
}

 

 

 

 

my custom UsernameTokenManager is:


using System;
using System.Xml;
using System.Web.Security;
using System.Security.Permissions;
using System.Security.Principal;
using Microsoft.Web.Services3.Security;
using Microsoft.Web.Services3.Security.Tokens;/// <summary>
 
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public class CustomUsernameTokenManager : UsernameTokenManager
 
    public CustomUsernameTokenManager() { }    /// <summary>
 
    public CustomUsernameTokenManager(XmlNodeList nodes) : base(nodes) { }    /// <summary>
 
    protected override string AuthenticateToken(UsernameToken token) {
    return "password";
    }
}

 

 

 

My web.config is:

< xml version="1.0" encoding="utf-8" >
<configuration>
  <configSections>
    <section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <system.web>
    <webServices>
      <soapExtensionImporterTypes>
        <add type="Microsoft.Web.Services3.Description.WseExtensionImporter, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </soapExtensionImporterTypes>
      <soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </webServices>
    <compilation>
      <assemblies>
        <add assembly="Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>
  </system.web>
  <microsoft.web.services3>
    <security>
      <securityTokenManager>
        <add type="CustomUsernameTokenManager" namespace=" http://www.hide-link.com/ " localName="UsernameToken" />
      </securityTokenManager>
    </security>
    <policy fileName="wse3policyCache.config" />
  </microsoft.web.services3>
</configuration>

 

 

 


My wse3policyCache.config is:


<policies xmlns=" http://www.hide-link.com/ ">
  <extensions>
    <extension name="usernameOverTransportSecurity" type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <extension name="requireActionHeader" type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </extensions>
  <policy name="usernameTokenSecurity">
    <usernameOverTransportSecurity />
    <requireActionHeader />
  </policy>
</policies>

 

Anyone see anything i've missed out As i said if i browse with internet explorer is always says 'hello world' when i'm not even passing a username and password.
Please help, i'm completely stuck! Thanks for your time :)



.NET Development14  
 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

Strange but even Microsofts example doesnt work, it always authenticates even without a username, password and certificate.

The example i tried is at:http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnpag2/html/WSS_Ch3_ImpDirectAuth_WSE30.asp

I simply downloades it , installed and run it.


 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

I've tried it on a remote server and still not working.

No matter what i do, it always authenticates true.

I need a basic sample/example using WSE 3.0 authenticating using username/password WITHOUT using a cerfificate.

If anyone can point to me one ill be eternally gratefull. I've searched all over google but theres little there on WSE 3.0 but a few for WSE 2.0.

 I've tried this tutorial at:http://cs.nerdbank.net/blogs/jmpinline/archive/2006/03/05/154.aspx but still not working.


 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

i've just about given up finding a simple example. why does microsoft have to make there examples so complicated

Why can't they just give us simple examples to build from the examples from WSE 3.0 are ok if your a bank or simular.


 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

Can someone please try out this WSE 3.0 example ive built: <no longer available>

 

The application takes a username and password and supposed to only let you in if the password is 'password'.

But it lets you in whatever you put for password.

Ive been trying for days to get it to work, if anyone can explain or correct what needs to be done, ill be very gratefull.

Thanks you, paul.


 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

I got WSE working!!
 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

Nope, only sort of working.

When using my app it lets you in with correct username & password and not without correct username & password. Thats good.

But, when you use internet explorer it lets you in even thou you havent provided a username and password.

Also when i uploaded it to a remote server, my app receives error 'Server unavailable, please try later.'

Heres a link to my new code: ,<no longer available>.

Thank you to those that downloaded my other code(about 10 of you), if you can check this out and correct me, ill be well happy.


 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

I've came up with version 3: <no longer available>

Works great on local machine, but move to remote server and it just reports 'Server unavailable, please try later.'

Ive tried uploading by 'VS2005/Publish Site' and by a 'ftp application'.

Anyone had any problems like this Works great until you upload it


 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

I've found out the problem with getting it to work on my remote server: it's about a trust level and That assembly does not
allow partially trusted callers

I changed a config file locally form trust level "full" to trust level "medium" in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config to simulate same enviroment as remote server.

I receive this error:

****** Exception Raised ******
System.Web.Services.Protocols.SoapException:
SOAP-Fault code: http://schemas.xmlsoap.org/soap/envelope/:Server
Message: System.Web.Services.Protocols.SoapHeaderException: Server unavailable,
please try later ---> System.ApplicationException: WSE842: The service pipeline
could not be created. ---> System.Configuration.ConfigurationErrorsException: WS
E032: There was an error loading the microsoft.web.services3 configuration secti
on. ---> System.Configuration.ConfigurationErrorsException: An error occurred cr
eating the configuration section handler for microsoft.web.services3: That assem
bly does not allow partially trusted callers. (D:\Program Files\Microsoft WSE\v3
.0\Samples\CS\QuickStart\Basic\BaseStockServiceWithUsernameToken\StockService\we
b.config line 63) ---> System.Security.SecurityException: That assembly does not
allow partially trusted callers.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly a
sm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, Secur
ityAction action, Object demand, IPermission permThatFailed)
at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMetho
dHandle method, IntPtr parent, UInt32 invocationFlags)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, B
inder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at System.Configuration.TypeUtil.InvokeCtorWithReflectionPermission(Construct
orInfo ctor)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactor
y.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord facto
ryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader read
er)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactor
y.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord
, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig,
ConfigXmlReader reader)
at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inpu
tIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object par
entConfig, ConfigXmlReader reader)
at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inp
utIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object pa
rentConfig, ConfigXmlReader reader, String filename, Int32 line)
The action that failed was:
LinkDemand
The assembly or AppDomain that failed was:
System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f1
1d50a3a
The Zone of the assembly that failed was:
MyComputer
The Url of the assembly that failed was:
file:///D:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50
a3a/System.Configuration.dll
--- End of inner exception stack trace ---
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, Se
ctionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord
sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factor
yRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boole
an getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String co
nfigKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Bool
ean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey,
Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Web.HttpContext.GetSection(String sectionName)
at Microsoft.Web.Services3.Configuration.WebServicesConfiguration.get_Current
()
--- End of inner exception stack trace ---
at Microsoft.Web.Services3.Configuration.WebServicesConfiguration.get_Current
()
at Microsoft.Web.Services3.Configuration.WebServicesConfiguration.get_Messagi
ngConfiguration()
at Microsoft.Web.Services3.WseProtocol.ModifyInitializedExtensions(PriorityGr
oup group, SoapExtension[] extensions)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClie
ntMessage message, WebResponse response, Stream responseStream, Boolean asyncCal
l)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodN
ame, Object[] parameters)
at localhost.StockServiceWse.StockQuoteRequest(String[] symbols) in D:\Progra
m Files\Microsoft WSE\v3.0\Samples\CS\QuickStart\Basic\BaseStockServiceWithUsern
ameToken\StockServiceClient\Web References\localhost\Reference.cs:line 79
at StockServiceClient.StockServiceClient.Run() in D:\Program Files\Microsoft
WSE\v3.0\Samples\CS\QuickStart\Basic\BaseStockServiceWithUsernameToken\StockServ
iceClient\StockServiceClient.cs:line 75
at StockServiceClient.StockServiceClient.Main(String[] args) in D:\Program Fi
les\Microsoft WSE\v3.0\Samples\CS\QuickStart\Basic\BaseStockServiceWithUsernameT
oken\StockServiceClient\StockServiceClient.cs:line 50
******************************

How do i rectify this problem on the remote server Is it something my service provider has to fix

Thanks for your time. Paul.


 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

Well, ive just terminated my account with www.liquidsix.co.uk with full refund. They say they can't fix the problem in a shared hosting enviroment.

Other services give ful WSE 3.0 support so im moving!

Anyone know of a good shared hoster for about £10(5$) a month


 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

I've moved to a new server now my code works great, thanks for those that tried my code.
 
 
mathec





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

Thank goodness I finally found a post on this. I can't seem to get to your code. The forum says <no longer available>. Would you mind sending or posting it again or explaining what you had to do to get the authentication working In my app I have followed all of the Micorosft instructions to the letter, and it still let's everyone in no matter what. My custom usernametoken manager doesn't even get called. Thanks!
 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

Sure, what's your email
 
 
MyraMains





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top


Hi gafferuk

What exactly did you have to have changed on the remote server for this to work My remote webserver is Win2000 running iis5 and .net 2.0. That may be my problem but MS says it is supported. Anyway I am getting the same "server unavilable" message. I just dont know what I need to change on the box to make it work. Thanks for any help you can offer.

Allen


 
 
gafferuk





PostPosted: ASMX Web Services and XML Serialization, Can you send me the code - thnx Top

The prolem i had is it was not set to full trust which couldnt be changed so i moved to another server company.

I have sent you an email with a wse example as an attachment. hope it works for you ok. Best of luck!