2
我有一個由Java客戶端調用的ASP.NET webservice。客戶端發送一個SOAP消息作爲輸入,但問題是它從來沒有達到我的web服務方法。我總是得到空輸入。我用的TraceListener,看到此警告這可能會導致問題:預計不會在這方面Webservice命名空間問題
元素:...預計元素:http://client.ns.url/:ListenerInput。
這就是客戶端發送:
<?xml version="1.0" encoding="utf-8"?>
<S:Envelope xmlns:S = "http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:Listener xmlns:ns2 = "http://client.ns.url/">
<ListenerInput>
<errorCode>0</errorCode>
<errorDescription>Success</errorDescription>
<firstPrice xsi:nil = "true" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"/>
</ListenerInput>
</ns2:Listener>
</S:Body>
</S:Envelope>
而且這裏是我的webmethod:
[System.Web.Services.WebServiceAttribute(Namespace = "http://client.ns.url/")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Web.Services.WebServiceBindingAttribute(Name = "ListenerWebServicePortSoapBinding", Namespace = "http://client.ns.url/")]
public partial class ListenerService : System.Web.Services.WebService
{
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://client.different.url/services/action/ListenerService/Listener", RequestElementName = "Listener", RequestNamespace = "http://client.ns.url/", ResponseNamespace = "http://client.ns.url/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return")]
public ListenerResponse Listener([System.Xml.Serialization.XmlElementAttribute("ListenerInput")]ListenerInput listenerInput)
{
..
這是輸入類:
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://client.ns.url")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class ListenerInput
{
public int errorCode;
public string errorDescription;
public float? firstPrice;
}
我應該怎麼做解決這個?以下是一些跟蹤日誌:
Calling IHttpHandler.ProcessRequest
Caller: System.Web.Services.Protocols.SyncSessionlessHandler#47754503::ProcessRequest()
Request Host Address: xxx
Request Url: [POST] http:/my.website/Listener.asmx
..
Calling XmlSerializer [Read Request]
Method: Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer#53218107::Deserialize(System.Web.Services.Protocols.SoapServerProtocol+SoapEnvelopeReader#4153573=.., (null))
Caller: System.Web.Services.Protocols.SoapServerProtocol#51389704::ReadParameters()
...
The element was not expected in this context: <ListenerInput>..</ListenerInput>. Expected elements: http://client.ns.url/:ListenerInput.
...
Return from XmlSerializer [Read Request]
Caller: System.Web.Services.Protocols.SoapServerProtocol#51389704::ReadParameters()
...
Calling ListenerResponse Listener(ListenerInput)
Method: ListenerService#64693151::Listener((null))
Caller: System.Web.Services.Protocols.SyncSessionlessHandler#47754503::Invoke()