2012-12-19 2 views
2

저는 웹 서비스에 익숙하지 않고 해결책을 찾으려고 노력하지만 해결책을 찾지 못했습니다.객체 속성으로 웹 서비스에 날짜를 전달하십시오.

웹 서비스에 매개 변수로 객체를 보내려고합니다. 다음과 같이

[WebMethod] 
    public bool CreatePatientService(Patient p) 
    { 
     AdminService AsRef = new AdminService(); 
     return AsRef.CreatePatient(p); 
    } 

내 환자 클래스입니다 :

[Serializable] 
public class Patient 
{ 

    public string NIC { get; set; } 
    public string FullName { get; set; } 
    public string FirstName { get; set; } 
    public string Surname { get; set; } 
    public string Title { get; set; } 
    public string Gender { get; set; } 
    public string CivilStatus { get; set; } 
    public DateTime DOB { get; set; } 
    public string Address1 { get; set; } 
    public string Address2 { get; set; } 
    public string Address3 { get; set; } 
} 

다음 내가 웹 서비스를 호출하는 SOAPUi을 사용했다.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <tem:CreatePatientService> 
     <!--Optional:--> 
     <tem:p> 
      <!--Optional:--> 
      <tem:NIC>15487236</tem:NIC> 
      <!--Optional:--> 
      <tem:FullName>awdss</tem:FullName> 
      <!--Optional:--> 
      <tem:FirstName>qewretr</tem:FirstName> 
      <!--Optional:--> 
      <tem:Surname>qscv</tem:Surname> 
      <!--Optional:--> 
      <tem:Title>Mr</tem:Title> 
      <!--Optional:--> 
      <tem:Gender>M</tem:Gender> 
      <tem:CivilStatus>S</tem:CivilStatus> 
      <tem:DOB>01/02/2002</tem:DOB> 
      <!--Optional:--> 
      <tem:Address1>nikhno</tem:Address1> 
      <!--Optional:--> 
      <tem:Address2>asdf</tem:Address2> 
      <!--Optional:--> 
      <tem:Address3>125</tem:Address3> 
     </tem:p> 
     </tem:CreatePatientService> 
    </soapenv:Body> 
</soapenv:Envelope> 

다음의주고는 다음과 같은 오류 :

i는 다음과 같이 요청을했다. 내가 어떻게 해결할 수 있니?

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body> 
     <soap:Fault> 
     <faultcode>soap:Client</faultcode> 
     <faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (19, 49). ---> System.FormatException: Input string was not in a correct format. 
    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal) 
    at System.Number.ParseUInt32(String value, NumberStyles options, NumberFormatInfo numfmt) 
    at System.UInt16.Parse(String s, NumberStyles style, NumberFormatInfo info) 
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read2_TblPatient(Boolean isNullable, Boolean checkType) 
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read7_CreatePatientService() 
    at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer8.Deserialize(XmlSerializationReader reader) 
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) 
    --- End of inner exception stack trace --- 
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) 
    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() 
    --- End of inner exception stack trace --- 
    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() 
    at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring> 
     <detail/> 
     </soap:Fault> 
    </soap:Body> 
</soap:Envelope> 

DOB (날짜)를 삭제 한 경우 올바르게 작동합니다.

다음 게시물을 참조하십시오. 그러나 그것을 cudn't는 그것을 작동한다.

Proper DateTime Format for a Web Service

도와주세요 ... 감사합니다 ...

답변

4

날짜 시간은 시간 값뿐만 아니라 날짜, 그래서 사실은 시간이없는 것을, 분, 초, 등이 필요 . 무엇이 그것을 깨고있다.

yyyy-MM-ddTHH:mm:ss.fffffffzzzzzz is the expected format. 

e.g. 2002-02-01T00:00:00.0 

XML deserialize DateTime Format

+0

고맙습니다 ......이 유 내 하루를 저장 .... 제대로 작동 .... :) – DevT

관련 문제