PDA

View Full Version : WSE Integration sample


aletz
11-23-2007, 01:25 AM
Hi Bruno,

The sample works fine, but when i try to consume the service the browser throws the follow message:

System.ApplicationException: Only SOAP request are permitted

so, i wrote an asp like this:

<%
Dim o_XmlhttpCaller

Set o_XmlhttpCaller = Server.CreateObject("Msxml2.XMLHTTP")

If ( o_XmlhttpCaller is nothing ) Then
Response.Write("<font color=red size=-1>Unable to create Object - Type: Msxml2.XMLHTTP<BR></font>")
Response.Write("Solution: Install MSXML 4.0")
End If

o_XmlhttpCaller.open "POST","http://gucoba_server/Calculator.Web/calculatorServiceWse.asmx", False
o_XmlhttpCaller.setRequestHeader "Content-Type", "text/xml"
o_XmlhttpCaller.setRequestHeader "SOAPAction","http://SpringCalculator/WebServices/Add"

Dim soapMessage

soapMessage = "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"

soapMessage = soapMessage & "<soap:Header>"
soapMessage = soapMessage & "<wsse:Security soap:mustUnderstand=""1"">"
soapMessage = soapMessage & "<wsse:UsernameToken namespaces>"
soapMessage = soapMessage & "<wsse:Username>bbaia</wsse:Username>"
soapMessage = soapMessage & "<wsse:Password Type=""type info"">bbaia</wsse:Password>"
soapMessage = soapMessage & "</wsse:UsernameToken>"
soapMessage = soapMessage & "<wsse:Security>"
soapMessage = soapMessage & "</soap:Header>"

soapMessage = soapMessage & "<soap:Body>"
soapMessage = soapMessage & "<Add xmlns=""http://SpringCalculator/WebServices"">"
soapMessage = soapMessage & "<n1>1</n1>"
soapMessage = soapMessage & "<n2>1</n2>"
soapMessage = soapMessage & "</Add>"
soapMessage = soapMessage & "</soap:Body>"
soapMessage = soapMessage & "</soap:Envelope>"

o_XmlhttpCaller.send(soapMessage)

Response.Write(o_XmlhttpCaller.responseText)

Set o_XmlhttpCaller = nothing
%>

And when i called the asp, the server sends me a error message:

http://schemas.xmlsoap.org/ws/2004/03/addressing/faultuuid:74666e69-166b-49f3-aaf3-c9db41562087http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymoussoap:ServerSystem.Web.Services.Protocols. SoapHeaderException: Server unavailable, please try later ---> System.Configuration.ConfigurationException: WSE032: There was an error loading the microsoft.web.services2 configuration section. ---> System.Configuration.ConfigurationErrorsException: WSE040: Type WebServerApp.MyUsernameTokenManager, WebServerApp could not be loaded. Please check the configuration file. en System.Configuration.BaseConfigurationRecord.Evalu ateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) en System.Configuration.BaseConfigurationRecord.Evalu ate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) en System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) en System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey, Boolean getLkg, Boolean checkPermission) en System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey) en System.Web.Configuration.HttpConfigurationSystem.S ystem.Configuration.Internal.IInternalConfigSystem .GetSection(String configKey) en System.Configuration.ConfigurationManager.GetSecti on(String sectionName) en System.Configuration.ConfigurationSettings.GetConf ig(String sectionName) en Microsoft.Web.Services2.Configuration.WebServicesC onfiguration.Initialize() --- Fin del seguimiento de la pila de la excepci�n interna --- en Microsoft.Web.Services2.Configuration.WebServicesC onfiguration.Initialize() en Microsoft.Web.Services2.WebServicesExtension.Befor eDeserializeServer(SoapServerMessage message) --- Fin del seguimiento de la pila de la excepci�n interna ---http://gucoba_server/Calculator.Web/calculatorServiceWse.asmx

so, i changed the web.config to....

<security>
<securityTokenManager type="WebServerApp.MyUsernameTokenManager, WebServerApp" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
qname="wsse:UsernameToken" />
</security>

and finally the server sends me the next message...

http://schemas.xmlsoap.org/ws/2004/03/addressing/faultuuid:fa5c1988-171b-4781-8ca5-09c3a0742701http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymoussoap:ServerSystem.Web.Services.Protocols. SoapHeaderException: Server unavailable, please try later ---> System.Configuration.ConfigurationException: WSE032: There was an error loading the microsoft.web.services2 configuration section. ---> System.Configuration.ConfigurationErrorsException: WSE041: Type Calculator.Web.MyUsernameTokenManager does not implement Microsoft.Web.Services2.Security.Tokens.ISecurityT okenManager. en System.Configuration.BaseConfigurationRecord.Evalu ateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) en System.Configuration.BaseConfigurationRecord.Evalu ate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) en System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) en System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey, Boolean getLkg, Boolean checkPermission) en System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey) en System.Web.Configuration.HttpConfigurationSystem.S ystem.Configuration.Internal.IInternalConfigSystem .GetSection(String configKey) en System.Configuration.ConfigurationManager.GetSecti on(String sectionName) en System.Configuration.ConfigurationSettings.GetConf ig(String sectionName) en Microsoft.Web.Services2.Configuration.WebServicesC onfiguration.Initialize() --- Fin del seguimiento de la pila de la excepci�n interna --- en Microsoft.Web.Services2.Configuration.WebServicesC onfiguration.Initialize() en Microsoft.Web.Services2.WebServicesExtension.Befor eDeserializeServer(SoapServerMessage message) --- Fin del seguimiento de la pila de la excepci�n interna ---http://gucoba_server/Calculator.Web/calculatorServiceWse.asmx

so, i hope that you can help me and undertand what is the problem... if my asp is bad. Iam running your demo in windows server 2003 and WSE 2.0.

in the other hand, i upgraded WSE 2.0 SP2 to SP3 and now, i have tried with a app client instead asp...the code is follow...

using System;
using ConsoleApplicationESBClient.gucoba_server;
using ConsoleApplicationESBClient.gucoba_server_Wse;

namespace ConsoleApplicationESBClient
{
class Program
{
static void Main(string[] args)
{
gucoba_server.calculatorService cs = new gucoba_server.calculatorService();
Console.WriteLine(cs.Add(2, 3));
Console.ReadLine();

gucoba_server_Wse.calculatorServiceWse cswse = new gucoba_server_Wse.calculatorServiceWse();
Console.WriteLine(cswse.Add(5, 8));
Console.ReadLine();
}
}
}

In the fiest service (without WSE) the app prints "5", but the service(WSE) prin the follow error:
The message must contain a wsa:To header

Can someone help me??

Thank you in advance.



Regards, Aletz

Hi,

I've updated the sample in the forum question page (http://opensource.atlassian.com/confluence/spring/display/NET/Forum+Questions).
Give it a try, and let me know.


In the sample I used the ASP.NET development server that comes with VS2005, but it should work in IIS too.
What you need is that your service name ends in .rem or .soap.

You can test the remote object accessing its metadata :
http://localhost:1444/RemotingWeb/RemotedCounter.rem?wsdl


Hoper this helps,
Bruno

Bruno Baia
12-11-2007, 04:03 PM
Hi,

First you need to upgrade to WSE 2.0 SP3.
Then, if you could make work the sample, I don't see the problem.

In your first issue, the problem is in the server side, it can't load the type :
WebServerApp.MyUsernameTokenManager, WebServerApp
Make sure it exists.

In you second issue, you have to get the service from the spring container :

IApplicationContext ctx = ContextRegistry.GetContext();
ICalculator calculatorSrv = (ICalculator) ctx["calculatorService"];



HTH,
Bruno

aletz
01-29-2008, 07:17 PM
i wrote a web consumer (Calculator) in vb6, like this...

Dim o_XmlhttpCaller As New MSXML2.XMLHTTP

Dim soapMessage As String

soapMessage = "<?xml version=""1.0"" encoding=""utf-8""?>"
soapMessage = soapMessage & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" " & _
"xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" " & _
"xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"" " & _
"xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"

soapMessage = soapMessage & "<soap:Header>"
'soapMessage = soapMessage & "<wsse:Security soap:mustUnderstand=""1"">"
soapMessage = soapMessage & "<wsse:UsernameToken namespaces>"
soapMessage = soapMessage & "<wsse:Username>bbaia</wsse:Username>"
soapMessage = soapMessage & "<wsse:Password>bbaia</wsse:Password>"
soapMessage = soapMessage & "</wsse:UsernameToken>"
soapMessage = soapMessage & "<wsse:Security>"
soapMessage = soapMessage & "</soap:Header>"

soapMessage = soapMessage & "<soap:Body>"
soapMessage = soapMessage & "<Add xmlns=""http://SpringCalculator/WebServices"">"
soapMessage = soapMessage & "<n1>7</n1>"
soapMessage = soapMessage & "<n2>3</n2>"
soapMessage = soapMessage & "</Add>"
soapMessage = soapMessage & "</soap:Body>"
soapMessage = soapMessage & "</soap:Envelope>"

With o_XmlhttpCaller
.open "POST", "http://server/Calculator.Web/calculatorServiceWse.asmx", False
.setRequestHeader "Content-Type", "text/xml"
.setRequestHeader "SOAPAction", "http://SpringCalculator/WebServices/Add"

.send (soapMessage)
msgbox (.responseText)
End With



but, i need send user and password throught the web service w/ WSE and the client sends me the next:

<?xml version="1.0" encoding="utf-8"?><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" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" 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"><soap:Header><wsa:Action>http://schemas.xmlsoap.org/ws/2004/03/addressing/fault</wsa:Action><wsa:MessageID>uuid:9b9bdc8d-d297-4e6a-b684-81ad66d7efd9</wsa:MessageID><wsa:RelatesTo>uuid:b8db4557-83ad-4299-91cf-1c495cda3729</wsa:RelatesTo><wsa:To>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:To><wsse:Security><wsu:Timestamp wsu:Id="Timestamp-553886be-7315-4fa5-9d46-7c102d52645c"><wsu:Created>2008-01-29T19:13:00Z</wsu:Created><wsu:Expires>2008-01-29T19:18:00Z</wsu:Expires></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><soap:Fault>
<faultcode>soap:Server</faultcode><faultstring>El servidor no puede procesar la solicitud. ---&gt; The message must contain a wsa:To header</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>

I tried in other client (vb6) like this...

With clnt
.MSSoapInit "http://server/RW/ServiceWse.asmx?wsdl"
.ConnectorProperty("AuthUser") = "aletz"
.ConnectorProperty("AuthPassword") = "aletz"


.ProcessMessage (Text1.Text)
End With

but it doesnt work..

can u give me a tip for a vb6 consumer w/ WSE.

Thank you in advance.

Regards, Aletz