我已经用C#创建了Web服务,并且需要使用PHP创建一个客户端。由于无法从PHP连接和使用Web服务中的函数和方法,因此我用C#创建了自己的Web服务,并且我可以管理几乎所有方法而没有问题。我可以使用所有将数据作为列表返回并在PHP中将其用作数组的方法。我无法做的是,我需要发送一些数据并将其保存在供Web Service使用的数据库中。
我可以成功发送所有必要的数据,但是当我打电话时
ServisSonucOfDenetimKayitSonuc8Zb117hL denkayit = badsClient.AsansorDenetimKayit(dkayit);
保存方法给了我
<br>badsClient.AsansorDenetimKayit[FaultException] kod: Client<br>FaultException message: Object reference not set to an instance of an object.<br>FaultException reason: Object reference not set to an instance of an object.<br>FaultException Action:
Server stack trace:
konum: System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
konum: System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
konum: System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
konum: System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
konum: System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
konum: System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
konum: WebServiceApp.AsansorDenetimServis.IBstbAsansorDenetimServis.AsansorDenetimKayit(DenetimKayit denetimKayit)
konum: WebServiceApp.AsansorDenetimServis.BstbAsansorDenetimServisClient.AsansorDenetimKayit(DenetimKayit denetimKayit)
konum: WebServiceApp.WebService.MuayeneKayit(String jsonArry)
调试时,我可以看到发送到该方法的所有数据,并且可以在断点行上看到它们。
serviceConnect(username, password);
[WebMethod]
public void serviceConnect(string usr, string pwd)
{
try
{
BstbAsansorDenetimServisClient Client = new BstbAsansorDenetimServisClient();
//var myEndpointBehavior = new SimpleEndpointBehavior();
//client.Endpoint.Behaviors.Add(myEndpointBehavior);
Client.ClientCredentials.UserName.UserName = usr;
Client.ClientCredentials.UserName.Password = pwd;
var basicHttpBinding = new BasicHttpBinding(
BasicHttpSecurityMode.TransportWithMessageCredential);
basicHttpBinding.Security.Message.ClientCredentialType =
BasicHttpMessageCredentialType.UserName;
badsClient = Client;
}
catch (FaultException<ServiceException> fe)
{
string hata = "TumIlleriSorgula[FaultException]: " + fe.Detail.Message +
"\r\nTumIlleriSorgula[FaultException]: " + fe.Detail.DebugInfo +
"\r\nTumIlleriSorgula[FaultException]: " + fe.Code.Name;
System.Diagnostics.Debug.WriteLine(hata);
}
catch (Exception se)
{
string hata = "TumIlleriSorgula[FaultException]: " + se.Message +
"\r\nTumIlleriSorgula[FaultException]: " + se.InnerException +
"\r\nTumIlleriSorgula[FaultException]: " + se.Source;
System.Diagnostics.Debug.WriteLine(hata);
}
}
sonuc += dkayit.DenetimKayitDetayAsansorBilgi[0].KimlikNumarasi;
sonuc += dkayit.DenetimKayitDetayBakimSozlesme[0].TseBelgeDurum;
sonuc += dkayit.DenetimKayitDetayBinaSorumlusuBilgileri[0].BinaSorumluAdSoyad;
sonuc += dkayit.DenetimKayitDetayFirmaBilgi[0].BakimFirmaAd;
sonuc += dkayit.DenetimKayitDetaySoru[0].SoruSkala;
sonuc += dkayit.DenetimKayitDetayTechizatBilgi[0].DemirbasNo;
sonuc += dkayit.DenetimKayitSonuc[0].DenetimKayitId;
sonuc += dkayit.DenetimTarih;
sonuc += "<br>[badsClient.AsansorDenetimKayit] [CommunicationState]: Current state: <br>" + badsClient.State.ToString();
ServisSonucOfDenetimKayitSonuc8Zb117hL denkayit = badsClient.AsansorDenetimKayit(dkayit); --> where I am getting error...