J
j.edwards
Hi,
I've been using WSE 2 SP3 to build a website that has a web service back
end, and asp.net front end. Up till this point I haven't had any problem
deploying, but on one of my client's sites I'm getting this sort of error:
-----------------------------------------
Client found response content type of '', but expected 'text/xml'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Client found response
content type of '', but expected 'text/xml'.
-----------------------------------------
The stack trace just points to the call of the web service, i.e.
Webservice.GetProject().
This error is triggered on calling a web service - even a simple one that
just returns a string. I've put trace.Write() in to make sure the web
service code was performing correctly which it is. The error is happening
somewhere between the end of the web method code and the result getting
returned to the calling webpage. I can call the web service from the html
interface and it works correctly. I've tested calling the webservice from a
vb.net app instead of asp.net project and it has the same error.
From the web searches I've done it seems that this is a generic error that
is really a front for some other error - i.e. an error message is getting
returned instead of the expected data in xml format. However, I can't debug
because I've only got limited vpn access and the client site is overseas.
The only way I can get everything working correctly is to remove all
references to WSE 2 SP3 - then it all works happily. I'm using impersonate
with integrated security but have tested the correct user credentials with
appropriate permissions is being used - and when WSE was removed the site
worked correctly with the impersonate stuff all being unchanged.
Does anyone have suggestions on what could fix this? Is it a bug with WSE?
-----------------------------------------
I have WSE set up to use a policy document - just so it expects a standard
UsernameToken.
<?xml version="1.0" encoding="utf-8" ?>
<policyDocument xmlns="http://schemas.microsoft.com/wse/2003/06/Policy">
<mappings xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy">
<defaultEndpoint>
<defaultOperation>
<request policy="" />
<response policy="" />
<fault policy="" />
</defaultOperation>
</endpoint>
</mappings>
<policies
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
xmlns:wssp="http://schemas.xmlsoap.org/ws/2002/12/secext"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"
xmlns:wssc="http://schemas.xmlsoap.org/ws/2004/04/sc"
xmlns:rp="http://schemas.xmlsoap.org/rp">
<wsp
olicy wsu:Id="signed-body-username">
<wssp:Integrity wsp:Usage="wsp:Required">
<wssp:TokenInfo>
<wssp:SecurityToken>
<wssp:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</wssp:TokenType>
</wssp:SecurityToken>
</wssp:TokenInfo>
<wssp:MessageParts xmlns:rp="http://schemas.xmlsoap.org/rp"
Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part">wsp:Body()
wse:Timestamp() wse:Addressing()</wssp:MessageParts>
</wssp:Integrity>
</wsp
olicy>
</policies>
</policyDocument>
-----------------------------------------
Here is my code for calling the web service ...
Public Shared Function GetDataWebservice() As WSProxy.DataWebServiceWse
Dim Result As New WSProxy.DataWebServiceWse
Dim httpContext As HttpContext = httpContext.Current
Dim config As Sage.Web.Config =
CType(httpContext.Items.Item("Config"), Sage.Web.Config)
'specifically state what the web service url will be on
'this is because it's "hardcoded" to be on "localhost" when in
development
'and it provides flexibility to run in various deployment situations
(such as developing from home)
'if this is done...
Dim sRootPath As String =
config.Environments.Active.Properties.Item("RootPath").ToString()
Result.Url = "http://" + httpContext.Request.Url.Host + sRootPath +
"/Webservice/DataWebservice.asmx"
'extend the webservice timeout so it can cope with longer things
like when community dir item added (which re-indexes full text catalogue on
insert new item)
Result.Timeout = 5 * (60 * 1000) '5 minutes
'get soap context
Dim soapContext As SoapContext = Result.RequestSoapContext
'create token for user login details
Dim iUserID As Integer
Try
'is a connection available to use?
Dim p As BasePage
p = CType(httpContext.Handler, BasePage)
If Not IsNothing(p.Conn) Then
iUserID = config.SessionManager.UserID
Else
iUserID = 0
End If
Catch ex As Exception
iUserID = 0
End Try
Dim t As New UsernameToken(iUserID.ToString(), iUserID.ToString(),
Microsoft.Web.Services2.Security.Tokens.PasswordOption.SendNone)
soapContext.Security.Tokens.Add(t)
Result.PreAuthenticate = True
Result.Credentials = System.Net.CredentialCache.DefaultCredentials
Return Result
End Function
I've been using WSE 2 SP3 to build a website that has a web service back
end, and asp.net front end. Up till this point I haven't had any problem
deploying, but on one of my client's sites I'm getting this sort of error:
-----------------------------------------
Client found response content type of '', but expected 'text/xml'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Client found response
content type of '', but expected 'text/xml'.
-----------------------------------------
The stack trace just points to the call of the web service, i.e.
Webservice.GetProject().
This error is triggered on calling a web service - even a simple one that
just returns a string. I've put trace.Write() in to make sure the web
service code was performing correctly which it is. The error is happening
somewhere between the end of the web method code and the result getting
returned to the calling webpage. I can call the web service from the html
interface and it works correctly. I've tested calling the webservice from a
vb.net app instead of asp.net project and it has the same error.
From the web searches I've done it seems that this is a generic error that
is really a front for some other error - i.e. an error message is getting
returned instead of the expected data in xml format. However, I can't debug
because I've only got limited vpn access and the client site is overseas.
The only way I can get everything working correctly is to remove all
references to WSE 2 SP3 - then it all works happily. I'm using impersonate
with integrated security but have tested the correct user credentials with
appropriate permissions is being used - and when WSE was removed the site
worked correctly with the impersonate stuff all being unchanged.
Does anyone have suggestions on what could fix this? Is it a bug with WSE?
-----------------------------------------
I have WSE set up to use a policy document - just so it expects a standard
UsernameToken.
<?xml version="1.0" encoding="utf-8" ?>
<policyDocument xmlns="http://schemas.microsoft.com/wse/2003/06/Policy">
<mappings xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy">
<defaultEndpoint>
<defaultOperation>
<request policy="" />
<response policy="" />
<fault policy="" />
</defaultOperation>
</endpoint>
</mappings>
<policies
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
xmlns:wssp="http://schemas.xmlsoap.org/ws/2002/12/secext"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"
xmlns:wssc="http://schemas.xmlsoap.org/ws/2004/04/sc"
xmlns:rp="http://schemas.xmlsoap.org/rp">
<wsp
<wssp:Integrity wsp:Usage="wsp:Required">
<wssp:TokenInfo>
<wssp:SecurityToken>
<wssp:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</wssp:TokenType>
</wssp:SecurityToken>
</wssp:TokenInfo>
<wssp:MessageParts xmlns:rp="http://schemas.xmlsoap.org/rp"
Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part">wsp:Body()
wse:Timestamp() wse:Addressing()</wssp:MessageParts>
</wssp:Integrity>
</wsp
</policies>
</policyDocument>
-----------------------------------------
Here is my code for calling the web service ...
Public Shared Function GetDataWebservice() As WSProxy.DataWebServiceWse
Dim Result As New WSProxy.DataWebServiceWse
Dim httpContext As HttpContext = httpContext.Current
Dim config As Sage.Web.Config =
CType(httpContext.Items.Item("Config"), Sage.Web.Config)
'specifically state what the web service url will be on
'this is because it's "hardcoded" to be on "localhost" when in
development
'and it provides flexibility to run in various deployment situations
(such as developing from home)
'if this is done...
Dim sRootPath As String =
config.Environments.Active.Properties.Item("RootPath").ToString()
Result.Url = "http://" + httpContext.Request.Url.Host + sRootPath +
"/Webservice/DataWebservice.asmx"
'extend the webservice timeout so it can cope with longer things
like when community dir item added (which re-indexes full text catalogue on
insert new item)
Result.Timeout = 5 * (60 * 1000) '5 minutes
'get soap context
Dim soapContext As SoapContext = Result.RequestSoapContext
'create token for user login details
Dim iUserID As Integer
Try
'is a connection available to use?
Dim p As BasePage
p = CType(httpContext.Handler, BasePage)
If Not IsNothing(p.Conn) Then
iUserID = config.SessionManager.UserID
Else
iUserID = 0
End If
Catch ex As Exception
iUserID = 0
End Try
Dim t As New UsernameToken(iUserID.ToString(), iUserID.ToString(),
Microsoft.Web.Services2.Security.Tokens.PasswordOption.SendNone)
soapContext.Security.Tokens.Add(t)
Result.PreAuthenticate = True
Result.Credentials = System.Net.CredentialCache.DefaultCredentials
Return Result
End Function