我们的网络服务问题 - 在尝试从网络服务获取信息时,我们发现错误:" 404未找到"。
任何人都可以看到可能出现的问题吗?
我们期待一个JSON字符串。
Service1.svc.vb
<ServiceContract(Namespace:="OurWebsiteURL-Here")>
<ServiceBehavior(Namespace:="OurWebsiteURL-Here")>
Public Class Service1
<OperationContract()>
<WebGet(UriTemplate:="/getPersonInfo/?personID={personID}&companyCode={companyCode}", BodyStyle:=WebMessageBodyStyle.Bare)>
Public Function getPersonInfo(ByVal personID As String, ByVal companyCode As String) As String
Dim dba As New DBAccess
Dim person As New PersonInfo
Dim m_SelPerson As String = String.Empty
Dim ds As DataSet = dba.GetPersonInfo(personID, companyCode)
If Not ds Is Nothing Then
Dim dr As DataRow = ds.Tables(0).Rows(0)
person = New PersonInfo
If Not String.IsNullOrEmpty(dr("UserID")) Then
person.UserID = Convert.ToInt32(dr("UserID"))
End If
person.PersonID = Convert.ToInt32(dr("PersonID"))
person.Company = dr("Company")
If Not IsDBNull(dr("Title")) Then
person.Title = dr("Title")
End If
If Not IsDBNull(dr("CellNum")) Then
person.CellNum = dr("CellNum")
End If
If Not IsDBNull(dr("EmergencyPhone")) Then
person.EmergencyPhone = dr("EmergencyPhone")
End If
If Not IsDBNull(dr("Email")) Then
person.Email = dr("Email")
End If
If Not IsDBNull(dr("PersonImageName")) Then
person.PersonImageName = dr("PersonImageName")
End If
'person.PersonImageName = dr("PersonImageName")
Dim oSerilzer As New System.Web.Script.Serialization.JavaScriptSerializer
m_SelPerson = oSerilzer.Serialize(person)
WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"
End If
'Return New MemoryStream(Encoding.UTF8.GetBytes(m_SelPerson))
Return m_SelPerson
End Function
&#13;
PersonInfo.vb
<DataContract()>
Public Class PersonInfo
Private m_userID As Integer
Private m_personID As Integer
Private m_title As String
Private m_company As String
Private m_cellNum As String
Private m_emergencyPhone As String
Private m_email As String
Private m_PersonImageName As String
<DataMember()>
Public Property UserID() As Integer
Get
Return m_userID
End Get
Set(ByVal value As Integer)
m_userID = value
End Set
End Property
<DataMember()>
Public Property PersonID() As Integer
Get
Return m_personID
End Get
Set(ByVal value As Integer)
m_personID = value
End Set
End Property
<DataMember()>
Public Property Title() As String
Get
Return m_title
End Get
Set(ByVal value As String)
m_title = value
End Set
End Property
<DataMember()>
Public Property Company() As String
Get
Return m_company
End Get
Set(ByVal value As String)
m_company = value
End Set
End Property
<DataMember()>
Public Property CellNum() As String
Get
Return m_cellNum
End Get
Set(ByVal value As String)
m_cellNum = value
End Set
End Property
<DataMember()>
Public Property EmergencyPhone() As String
Get
Return m_emergencyPhone
End Get
Set(ByVal value As String)
m_emergencyPhone = value
End Set
End Property
<DataMember()>
Public Property Email() As String
Get
Return m_email
End Get
Set(ByVal value As String)
m_email = value
End Set
End Property
<DataMember()>
Public Property PersonImageName As String
Get
Return m_PersonImageName
End Get
Set(ByVal value As String)
m_PersonImageName = value
End Set
End Property
End Class
&#13;
的Web.config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="LocalDBConnectionTest" connectionString="data source=URL;initial catalog=TEST;persist security info=True;user id=sa;password=test;Connection Timeout=60" providerName="System.Data.SqlClient" />
<customErrors mode="On"/>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="4800" maxRequestLength="500000000"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SoapEndpointBinding"
closeTimeout="00:10:00"
maxBufferPoolSize="250000000"
maxReceivedMessageSize="250000000"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00">
<readerQuotas maxDepth="4500000" maxStringContentLength="4500000" maxBytesPerRead="40960000" maxNameTableCharCount="250000000" maxArrayLength="4500000"/>
<security mode="Transport"/>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="RestEndpointBinding"
closeTimeout="00:10:00"
maxBufferPoolSize="250000000"
maxReceivedMessageSize="250000000"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00">
<readerQuotas maxDepth="4500000" maxStringContentLength="4500000" maxBytesPerRead="40960000" maxNameTableCharCount="250000000" maxArrayLength="4500000"/>
<security mode="None"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="WCFDispatchWebService.Service1" behaviorConfiguration="ServiceBehavior">
<endpoint address="SOAP" binding="basicHttpBinding" contract="WCFDispatchWebService.Service1" bindingConfiguration="SoapEndpointBinding" bindingNamespace="OurURL-HERE" />
<endpoint address="REST" binding="webHttpBinding" contract="WCFDispatchWebService.Service1" bindingConfiguration="RestEndpointBinding" bindingNamespace="OurURL-HERE" behaviorConfiguration="RestEndpointBehavior"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="RestEndpointBehavior">
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security >
<requestFiltering>
<requestLimits maxAllowedContentLength="500000000"></requestLimits>
</requestFiltering>
</security>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
&#13;
DBACCESS
Public Function GetPersonInfo(ByVal personID As String, ByVal companyCode As String) As DataSet
Dim ds As DataSet = Nothing
Try
' Prepare the arguement list
Dim storedProc As String = "spGetPersonInfoFromPersonID"
Dim SqlParameterList As New List(Of SqlParameter)
SqlParameterList.Add(New SqlParameter("@inPersonID", Convert.ToInt32(personID)))
' Execute the SP and store the dataset
ds = SQLHelper.ExecuteNonQueryDataSet(Globals.GetConnectionStringMain(companyCode), CommandType.StoredProcedure, storedProc, SqlParameterList.ToArray())
' Check for an empty dataset
If ds.Tables(0).Rows.Count <= 0 Then
ds = Nothing
End If
Catch
End Try
Return ds
End Function
&#13;
调试并获取有效JSON文件后我们得到的错误:
无法调用该服务。可能的原因:服务离线或无法访问;客户端配置与代理不匹配;现有代理无效。有关更多详细信息,请参阅堆栈跟踪。您可以尝试通过启动新代理,还原到默认配置或刷新服务来恢复。
请求频道在00:00:59.9376004之后等待回复时超时。增加传递给Request的调用的超时值或增加Binding上的SendTimeout值。分配给此操作的时间可能是较长超时的一部分。
Server stack trace:
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Service1.getPersonInfo(String personID, String companyCode)
at Service1Client.getPersonInfo(String personID, String companyCode)
Inner Exception:
The HTTP request to 'http://localhost:56329/Service1.svc/SOAP' has exceeded the allotted timeout of 00:00:59.9680000. The time allotted to this operation may have been a portion of a longer timeout.
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
Inner Exception:
The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
&#13;