서비스 참조로 프로젝트에 추가 된 외부 웹 서비스가 있습니다. 웹 서비스에서 제공하는 메서드와 속성으로 충분합니까? 여기 이 모양을 어떻게입니다 : 그와외부 wcf 웹 서비스는 어떻게 호출해야합니까?
//Classes from web service
HHserviceClient h = new HHserviceClient();
HHPostPropertyRequest r = new HHPostPropertyRequest
{
//Web service properties
Amenities = c.Amenities,
....
MobileNo = c.MobileNo
};
//Method from web service
h.PostProperty(r);
문제 것은 내가 혼란 스러워요 그 이유는, HHserviceClient이 호출 할 때 예외가 발생 NullReference이다 - 나는 몇 가지 추가 작업을 할 HttpClient를 같은 모든 .NET 클래스를 호출해야합니다. 필자는 외부 wcf 웹 서비스로 어떤 일을하기도 전에 한 번도 본 적이 없었습니다. 그래서 나는 완전히 새롭고 조언을 구했습니다.
업데이트.
var rq = new HHPostPropertyRequest
{
Amenities = c.Amenities,
Area = c.Area,
BathRooms = c.BathRooms,
Bedrooms = c.Bedrooms,
City = c.City,
Company = c.Company,
Contact = c.Contact,
Country = c.Country,
CustomerID = 1000,
Description = c.Description,
Email = c.Email,
LandLineNo = c.LandLineNo,
Lattitude = c.Lattitude,
Location = c.Location,
Longitude = c.Longitude,
MobileNo = c.MobileNo
};
BasicHttpBinding myBinding = new BasicHttpBinding();
EndpointAddress myEndpoint = new EndpointAddress("http://198.38.94.85/hhsvc/hhservice.svc/postproperty");
ChannelFactory<IHHservice> myChannelFactory = new ChannelFactory<IHHservice>(myBinding, myEndpoint);
IHHservice HHservice = myChannelFactory.CreateChannel();
var result = HHservice.PostProperty(rq);
((IClientChannel)HHservice).Close();
myChannelFactory.Close();
문제가 있습니까? Visual Studio –
을 통해 서비스 참조를 추가하면 일반적으로 이미 모든 것을 갖게됩니다. 그래서 혼란 스럽습니다. HHserviceClient가 호출 될 때 null 참조 예외가 throw됩니다. –
예외 스택 추적을 표시 할 수 있습니까? Property 객체에 모든 속성에 대한 setter \ getters가 있습니까? –