我在我的一个项目中添加了一个服务,不确定是否在.NET中进行此服务,当我对其中一个操作执行呼叫时,我会得到一系列对象。1个元素,此元素充满了无效的值,我已经与提琴手进行了检查,并且数据响应正确。你们知道为什么会发生这种情况吗?
Soapresponse结构:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<searchOrderResponse xmlns="http://xml.comcast.com/nationalaccountsportal/services">
<searchOrderReturn>
<ns1:searchResult xsi:type="ns1:OrderDetails" xmlns:ns1="http://xml.comcast.com/nationalaccountsportal/types"> <!-- The data -->
<ns2:searchResult xsi:type="ns2:OrderDetails" xmlns:ns2="http://xml.comcast.com/nationalaccountsportal/types">
自动化类定义:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="searchOrderResponse", WrapperNamespace="http://xml.comcast.com/nationalaccountsportal/services", IsWrapped=true)]
internal partial class searchOrderResponse {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://xml.comcast.com/nationalaccountsportal/services", Order=0)]
[System.Xml.Serialization.XmlElementAttribute("searchOrderReturn")]
public OrderDetails[] searchOrderReturn;
public searchOrderResponse() {
}
public searchOrderResponse(OrderDetails[] searchOrderReturn) {
this.searchOrderReturn = searchOrderReturn;
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1590.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://xml.comcast.com/nationalaccountsportal/types")]
public partial class OrderDetails : object, System.ComponentModel.INotifyPropertyChanged {
wsdl中的searchorderresponse定义:
<element name="searchOrderResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="searchOrderReturn" type="tns1:OrderDetails"/>
</sequence>
</complexType>
</element>
谢谢!
我忘了更新大家,问题是WSDL正在错误地描述响应,从而导致VS生成不正确的代码,它缺少一个标签,或者随着VS生成'em的'em,一个"响应类型",所以我添加了:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1590.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://xml.comcast.com/nationalaccountsportal/types")]
public partial class SearchOrderResponseType : object, System.ComponentModel.INotifyPropertyChanged
{
private OrderDetails[] searchResultField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 0)]
public OrderDetails[] searchResult
{
get
{
return this.searchResultField;
}
set
{
this.searchResultField = value;
this.RaisePropertyChanged("searchResult");
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName)
{
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null))
{
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
请注意,该属性称为searchResult,就像上面的响应结构一样,类的名称可能是不同的,但是我将其保留为SearchOrderResponseType,因为这是VS的命名方式。此后,您必须在响应类中更改返回类型,如下所示:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.MessageContractAttribute(WrapperName="searchOrderResponse", WrapperNamespace="http://xml.comcast.com/nationalaccountsportal/services", IsWrapped=true)]
internal partial class searchOrderResponse {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://xml.comcast.com/nationalaccountsportal/services", Order=0)]
[System.Xml.Serialization.XmlElementAttribute("searchOrderReturn")]
public SearchOrderResponseType searchOrderReturn;
public searchOrderResponse() {
}
public searchOrderResponse(SearchOrderResponseType searchOrderReturn) {
this.searchOrderReturn = searchOrderReturn;
}
}
因此,基本上,这只是一个缺少的班级,希望这有帮助