admin管理员组

文章数量:1023738

I'm developing a wordpress plugin and need to perform soap calls. After understanding that cURL isn't option (manage to run some code in my browser but can't make it work within the plugin), I'm trying to use SoapClient by php5.

the connection seems to be working since i'm able to print out the __getFunctions() var:

StatusResponse Status(Status $parameters)" 
[1]=> string(65) "AdministrationResponse Administration(Administration $parameters)" 
[2]=> string(74) "FetchPropertyListResponse FetchPropertyList(FetchPropertyList $parameters)" 
[3]=> string(77) "FetchPropertyGroupResponse FetchPropertyGroup(FetchPropertyGroup $parameters)" 
[4]=> string(74) "FetchPropertyInfoResponse FetchPropertyInfo(FetchPropertyInfo $parameters)" 
[5]=> string(98) "FetchPropertyAvailabilityResponse FetchPropertyAvailability(FetchPropertyAvailability $parameters)" 
[6]=> string(95) "FetchPropertyRateSummaryResponse FetchPropertyRateSummary(FetchPropertyRateSummary $parameters)" 
[7]=> string(86) "FetchStayAvailabilityResponse FetchStayAvailability(FetchStayAvailability $parameters)" 
[8]=> string(71) "PlaceReservationResponse PlaceReservation(PlaceReservation $parameters)" 
[9]=> string(89) "CheckReservationExistsResponse CheckReservationExists(CheckReservationExists $parameters)" 
[10]=> string(74) "CancelReservationResponse CancelReservation(CancelReservation $parameters)" 
[11]=> string(56) "PostPaymentResponse PostPayment(PostPayment $parameters)" 
[12]=> string(53) "PostChargeResponse PostCharge(PostCharge $parameters)" 
[13]=> string(44) "PostEFTResponse PostEFT(PostEFT $parameters)" 
[14]=> string(56) "PostMessageResponse PostMessage(PostMessage $parameters)" 
[15]=> string(50) "PlaceHoldResponse PlaceHold(PlaceHold $parameters)" 
[16]=> string(53) "CancelHoldResponse CancelHold(CancelHold $parameters)" 
[17]=> string(62) "ValidateAgentResponse ValidateAgent(ValidateAgent $parameters)" 
[18]=> string(68) "ValidateCompanyResponse ValidateCompany(ValidateCompany $parameters)" 
[19]=> string(80) "FetchPropertyReportResponse FetchPropertyReport(FetchPropertyReport $parameters)" 
[20]=> string(41) "StatusResponse Status(Status $parameters)" 
[21]=> string(65) "AdministrationResponse Administration(Administration $parameters)" 
[22]=> string(74) "FetchPropertyListResponse FetchPropertyList(FetchPropertyList $parameters)" 
[23]=> string(77) "FetchPropertyGroupResponse FetchPropertyGroup(FetchPropertyGroup $parameters)" 
[24]=> string(74) "FetchPropertyInfoResponse FetchPropertyInfo(FetchPropertyInfo $parameters)" 
[25]=> string(98) "FetchPropertyAvailabilityResponse FetchPropertyAvailability(FetchPropertyAvailability $parameters)" 
[26]=> string(95) "FetchPropertyRateSummaryResponse FetchPropertyRateSummary(FetchPropertyRateSummary $parameters)" 
[27]=> string(86) "FetchStayAvailabilityResponse FetchStayAvailability(FetchStayAvailability $parameters)" 
[28]=> string(71) "PlaceReservationResponse PlaceReservation(PlaceReservation $parameters)" 
[29]=> string(89) "CheckReservationExistsResponse CheckReservationExists(CheckReservationExists $parameters)" 
[30]=> string(74) "CancelReservationResponse CancelReservation(CancelReservation $parameters)" 
[31]=> string(56) "PostPaymentResponse PostPayment(PostPayment $parameters)" 
[32]=> string(53) "PostChargeResponse PostCharge(PostCharge $parameters)" 
[33]=> string(44) "PostEFTResponse PostEFT(PostEFT $parameters)" 
[34]=> string(56) "PostMessageResponse PostMessage(PostMessage $parameters)" 
[35]=> string(50) "PlaceHoldResponse PlaceHold(PlaceHold $parameters)" 
[36]=> string(53) "CancelHoldResponse CancelHold(CancelHold $parameters)" 
[37]=> string(62) "ValidateAgentResponse ValidateAgent(ValidateAgent $parameters)" 
[38]=> string(68) "ValidateCompanyResponse ValidateCompany(ValidateCompany $parameters)" 
[39]=> string(80) "FetchPropertyReportResponse FetchPropertyReport(FetchPropertyReport $parameters)" }

When i try to call to one of the functions i get an "Object reference not set to an instance of an object." Error. I'm familiar with this error from the time before i manage to send soap request throw POSTMAN chrome plugin. i get this error when the body part was missing details.

this is the request i manage to send from POSTMAN:

<soap:Envelope xmlns:xsi=""
                    xmlns:xsd=""
                    xmlns:soap="/">
  <soap:Header>
    <ChannelCredentials xmlns="ChartsWeb">
      <Username>???</Username>
      <Password>???</Password>
    </ChannelCredentials>
  </soap:Header>
  <soap:Body>
    <FetchPropertyInfo xmlns="ChartsWeb">
      <FetchPropertyInfoRequest>
        <PropertyInfoRequests>
          <PropertyInfoRequest PropCode="???" MySite="???"/>
        </PropertyInfoRequests>
      </FetchPropertyInfoRequest>
    </FetchPropertyInfo>
  </soap:Body>
</soap:Envelope>

and get the expected result.

this is the current code i get :

<?php




$client = new SoapClient(".asmx?wsdl", array('trace' => 1));

$ns = 'ChartsWeb'; //Namespace of the WS. 

//Body of the Soap Header. 
$headerbody = array('Username' => $username, 
                    'Password' => $password,
                    'LoggingRequest' => True);

//Create Soap Header.        
 $header = new SOAPHeader($ns, 'ChannelCredentials', $headerbody);        

// //set the Headers of Soap Client. 
 $client->__setSoapHeaders($header); 

$fcs = $client->__getFunctions();

$res_FetchPropertyInfo = $client->FetchPropertyInfo(array("PropCode" => $prop_code, "MySite" => $my_site));

var_dump($client->__getLastRequest());

and this is the request it produce:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="/" xmlns:ns1="ChartsWeb">
    <SOAP-ENV:Header>
        <ns1:ChannelCredentials>
            <ns1:Username>???</ns1:Username>
            <ns1:Password>???</ns1:Password>
            <ns1:LoggingRequest>true</ns1:LoggingRequest>
        </ns1:ChannelCredentials>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:FetchPropertyInfo/>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

it seems like something with my body don't setup correctly..

anyone deal with this problem?

I'm developing a wordpress plugin and need to perform soap calls. After understanding that cURL isn't option (manage to run some code in my browser but can't make it work within the plugin), I'm trying to use SoapClient by php5.

the connection seems to be working since i'm able to print out the __getFunctions() var:

StatusResponse Status(Status $parameters)" 
[1]=> string(65) "AdministrationResponse Administration(Administration $parameters)" 
[2]=> string(74) "FetchPropertyListResponse FetchPropertyList(FetchPropertyList $parameters)" 
[3]=> string(77) "FetchPropertyGroupResponse FetchPropertyGroup(FetchPropertyGroup $parameters)" 
[4]=> string(74) "FetchPropertyInfoResponse FetchPropertyInfo(FetchPropertyInfo $parameters)" 
[5]=> string(98) "FetchPropertyAvailabilityResponse FetchPropertyAvailability(FetchPropertyAvailability $parameters)" 
[6]=> string(95) "FetchPropertyRateSummaryResponse FetchPropertyRateSummary(FetchPropertyRateSummary $parameters)" 
[7]=> string(86) "FetchStayAvailabilityResponse FetchStayAvailability(FetchStayAvailability $parameters)" 
[8]=> string(71) "PlaceReservationResponse PlaceReservation(PlaceReservation $parameters)" 
[9]=> string(89) "CheckReservationExistsResponse CheckReservationExists(CheckReservationExists $parameters)" 
[10]=> string(74) "CancelReservationResponse CancelReservation(CancelReservation $parameters)" 
[11]=> string(56) "PostPaymentResponse PostPayment(PostPayment $parameters)" 
[12]=> string(53) "PostChargeResponse PostCharge(PostCharge $parameters)" 
[13]=> string(44) "PostEFTResponse PostEFT(PostEFT $parameters)" 
[14]=> string(56) "PostMessageResponse PostMessage(PostMessage $parameters)" 
[15]=> string(50) "PlaceHoldResponse PlaceHold(PlaceHold $parameters)" 
[16]=> string(53) "CancelHoldResponse CancelHold(CancelHold $parameters)" 
[17]=> string(62) "ValidateAgentResponse ValidateAgent(ValidateAgent $parameters)" 
[18]=> string(68) "ValidateCompanyResponse ValidateCompany(ValidateCompany $parameters)" 
[19]=> string(80) "FetchPropertyReportResponse FetchPropertyReport(FetchPropertyReport $parameters)" 
[20]=> string(41) "StatusResponse Status(Status $parameters)" 
[21]=> string(65) "AdministrationResponse Administration(Administration $parameters)" 
[22]=> string(74) "FetchPropertyListResponse FetchPropertyList(FetchPropertyList $parameters)" 
[23]=> string(77) "FetchPropertyGroupResponse FetchPropertyGroup(FetchPropertyGroup $parameters)" 
[24]=> string(74) "FetchPropertyInfoResponse FetchPropertyInfo(FetchPropertyInfo $parameters)" 
[25]=> string(98) "FetchPropertyAvailabilityResponse FetchPropertyAvailability(FetchPropertyAvailability $parameters)" 
[26]=> string(95) "FetchPropertyRateSummaryResponse FetchPropertyRateSummary(FetchPropertyRateSummary $parameters)" 
[27]=> string(86) "FetchStayAvailabilityResponse FetchStayAvailability(FetchStayAvailability $parameters)" 
[28]=> string(71) "PlaceReservationResponse PlaceReservation(PlaceReservation $parameters)" 
[29]=> string(89) "CheckReservationExistsResponse CheckReservationExists(CheckReservationExists $parameters)" 
[30]=> string(74) "CancelReservationResponse CancelReservation(CancelReservation $parameters)" 
[31]=> string(56) "PostPaymentResponse PostPayment(PostPayment $parameters)" 
[32]=> string(53) "PostChargeResponse PostCharge(PostCharge $parameters)" 
[33]=> string(44) "PostEFTResponse PostEFT(PostEFT $parameters)" 
[34]=> string(56) "PostMessageResponse PostMessage(PostMessage $parameters)" 
[35]=> string(50) "PlaceHoldResponse PlaceHold(PlaceHold $parameters)" 
[36]=> string(53) "CancelHoldResponse CancelHold(CancelHold $parameters)" 
[37]=> string(62) "ValidateAgentResponse ValidateAgent(ValidateAgent $parameters)" 
[38]=> string(68) "ValidateCompanyResponse ValidateCompany(ValidateCompany $parameters)" 
[39]=> string(80) "FetchPropertyReportResponse FetchPropertyReport(FetchPropertyReport $parameters)" }

When i try to call to one of the functions i get an "Object reference not set to an instance of an object." Error. I'm familiar with this error from the time before i manage to send soap request throw POSTMAN chrome plugin. i get this error when the body part was missing details.

this is the request i manage to send from POSTMAN:

<soap:Envelope xmlns:xsi="http://www.w3/2001/XMLSchema-instance"
                    xmlns:xsd="http://www.w3/2001/XMLSchema"
                    xmlns:soap="http://schemas.xmlsoap/soap/envelope/">
  <soap:Header>
    <ChannelCredentials xmlns="ChartsWeb">
      <Username>???</Username>
      <Password>???</Password>
    </ChannelCredentials>
  </soap:Header>
  <soap:Body>
    <FetchPropertyInfo xmlns="ChartsWeb">
      <FetchPropertyInfoRequest>
        <PropertyInfoRequests>
          <PropertyInfoRequest PropCode="???" MySite="???"/>
        </PropertyInfoRequests>
      </FetchPropertyInfoRequest>
    </FetchPropertyInfo>
  </soap:Body>
</soap:Envelope>

and get the expected result.

this is the current code i get :

<?php




$client = new SoapClient("http://stage-chartsweb.chartspms.au/webservices/service.asmx?wsdl", array('trace' => 1));

$ns = 'ChartsWeb'; //Namespace of the WS. 

//Body of the Soap Header. 
$headerbody = array('Username' => $username, 
                    'Password' => $password,
                    'LoggingRequest' => True);

//Create Soap Header.        
 $header = new SOAPHeader($ns, 'ChannelCredentials', $headerbody);        

// //set the Headers of Soap Client. 
 $client->__setSoapHeaders($header); 

$fcs = $client->__getFunctions();

$res_FetchPropertyInfo = $client->FetchPropertyInfo(array("PropCode" => $prop_code, "MySite" => $my_site));

var_dump($client->__getLastRequest());

and this is the request it produce:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap/soap/envelope/" xmlns:ns1="ChartsWeb">
    <SOAP-ENV:Header>
        <ns1:ChannelCredentials>
            <ns1:Username>???</ns1:Username>
            <ns1:Password>???</ns1:Password>
            <ns1:LoggingRequest>true</ns1:LoggingRequest>
        </ns1:ChannelCredentials>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:FetchPropertyInfo/>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

it seems like something with my body don't setup correctly..

anyone deal with this problem?

Share Improve this question asked Jan 13, 2017 at 11:07 bar avitalbar avital 111 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Never mind, find my error.. just need to assign to the function associate array according to the body structure. sometime all u need is just to write things down:)

I'm developing a wordpress plugin and need to perform soap calls. After understanding that cURL isn't option (manage to run some code in my browser but can't make it work within the plugin), I'm trying to use SoapClient by php5.

the connection seems to be working since i'm able to print out the __getFunctions() var:

StatusResponse Status(Status $parameters)" 
[1]=> string(65) "AdministrationResponse Administration(Administration $parameters)" 
[2]=> string(74) "FetchPropertyListResponse FetchPropertyList(FetchPropertyList $parameters)" 
[3]=> string(77) "FetchPropertyGroupResponse FetchPropertyGroup(FetchPropertyGroup $parameters)" 
[4]=> string(74) "FetchPropertyInfoResponse FetchPropertyInfo(FetchPropertyInfo $parameters)" 
[5]=> string(98) "FetchPropertyAvailabilityResponse FetchPropertyAvailability(FetchPropertyAvailability $parameters)" 
[6]=> string(95) "FetchPropertyRateSummaryResponse FetchPropertyRateSummary(FetchPropertyRateSummary $parameters)" 
[7]=> string(86) "FetchStayAvailabilityResponse FetchStayAvailability(FetchStayAvailability $parameters)" 
[8]=> string(71) "PlaceReservationResponse PlaceReservation(PlaceReservation $parameters)" 
[9]=> string(89) "CheckReservationExistsResponse CheckReservationExists(CheckReservationExists $parameters)" 
[10]=> string(74) "CancelReservationResponse CancelReservation(CancelReservation $parameters)" 
[11]=> string(56) "PostPaymentResponse PostPayment(PostPayment $parameters)" 
[12]=> string(53) "PostChargeResponse PostCharge(PostCharge $parameters)" 
[13]=> string(44) "PostEFTResponse PostEFT(PostEFT $parameters)" 
[14]=> string(56) "PostMessageResponse PostMessage(PostMessage $parameters)" 
[15]=> string(50) "PlaceHoldResponse PlaceHold(PlaceHold $parameters)" 
[16]=> string(53) "CancelHoldResponse CancelHold(CancelHold $parameters)" 
[17]=> string(62) "ValidateAgentResponse ValidateAgent(ValidateAgent $parameters)" 
[18]=> string(68) "ValidateCompanyResponse ValidateCompany(ValidateCompany $parameters)" 
[19]=> string(80) "FetchPropertyReportResponse FetchPropertyReport(FetchPropertyReport $parameters)" 
[20]=> string(41) "StatusResponse Status(Status $parameters)" 
[21]=> string(65) "AdministrationResponse Administration(Administration $parameters)" 
[22]=> string(74) "FetchPropertyListResponse FetchPropertyList(FetchPropertyList $parameters)" 
[23]=> string(77) "FetchPropertyGroupResponse FetchPropertyGroup(FetchPropertyGroup $parameters)" 
[24]=> string(74) "FetchPropertyInfoResponse FetchPropertyInfo(FetchPropertyInfo $parameters)" 
[25]=> string(98) "FetchPropertyAvailabilityResponse FetchPropertyAvailability(FetchPropertyAvailability $parameters)" 
[26]=> string(95) "FetchPropertyRateSummaryResponse FetchPropertyRateSummary(FetchPropertyRateSummary $parameters)" 
[27]=> string(86) "FetchStayAvailabilityResponse FetchStayAvailability(FetchStayAvailability $parameters)" 
[28]=> string(71) "PlaceReservationResponse PlaceReservation(PlaceReservation $parameters)" 
[29]=> string(89) "CheckReservationExistsResponse CheckReservationExists(CheckReservationExists $parameters)" 
[30]=> string(74) "CancelReservationResponse CancelReservation(CancelReservation $parameters)" 
[31]=> string(56) "PostPaymentResponse PostPayment(PostPayment $parameters)" 
[32]=> string(53) "PostChargeResponse PostCharge(PostCharge $parameters)" 
[33]=> string(44) "PostEFTResponse PostEFT(PostEFT $parameters)" 
[34]=> string(56) "PostMessageResponse PostMessage(PostMessage $parameters)" 
[35]=> string(50) "PlaceHoldResponse PlaceHold(PlaceHold $parameters)" 
[36]=> string(53) "CancelHoldResponse CancelHold(CancelHold $parameters)" 
[37]=> string(62) "ValidateAgentResponse ValidateAgent(ValidateAgent $parameters)" 
[38]=> string(68) "ValidateCompanyResponse ValidateCompany(ValidateCompany $parameters)" 
[39]=> string(80) "FetchPropertyReportResponse FetchPropertyReport(FetchPropertyReport $parameters)" }

When i try to call to one of the functions i get an "Object reference not set to an instance of an object." Error. I'm familiar with this error from the time before i manage to send soap request throw POSTMAN chrome plugin. i get this error when the body part was missing details.

this is the request i manage to send from POSTMAN:

<soap:Envelope xmlns:xsi=""
                    xmlns:xsd=""
                    xmlns:soap="/">
  <soap:Header>
    <ChannelCredentials xmlns="ChartsWeb">
      <Username>???</Username>
      <Password>???</Password>
    </ChannelCredentials>
  </soap:Header>
  <soap:Body>
    <FetchPropertyInfo xmlns="ChartsWeb">
      <FetchPropertyInfoRequest>
        <PropertyInfoRequests>
          <PropertyInfoRequest PropCode="???" MySite="???"/>
        </PropertyInfoRequests>
      </FetchPropertyInfoRequest>
    </FetchPropertyInfo>
  </soap:Body>
</soap:Envelope>

and get the expected result.

this is the current code i get :

<?php




$client = new SoapClient(".asmx?wsdl", array('trace' => 1));

$ns = 'ChartsWeb'; //Namespace of the WS. 

//Body of the Soap Header. 
$headerbody = array('Username' => $username, 
                    'Password' => $password,
                    'LoggingRequest' => True);

//Create Soap Header.        
 $header = new SOAPHeader($ns, 'ChannelCredentials', $headerbody);        

// //set the Headers of Soap Client. 
 $client->__setSoapHeaders($header); 

$fcs = $client->__getFunctions();

$res_FetchPropertyInfo = $client->FetchPropertyInfo(array("PropCode" => $prop_code, "MySite" => $my_site));

var_dump($client->__getLastRequest());

and this is the request it produce:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="/" xmlns:ns1="ChartsWeb">
    <SOAP-ENV:Header>
        <ns1:ChannelCredentials>
            <ns1:Username>???</ns1:Username>
            <ns1:Password>???</ns1:Password>
            <ns1:LoggingRequest>true</ns1:LoggingRequest>
        </ns1:ChannelCredentials>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:FetchPropertyInfo/>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

it seems like something with my body don't setup correctly..

anyone deal with this problem?

I'm developing a wordpress plugin and need to perform soap calls. After understanding that cURL isn't option (manage to run some code in my browser but can't make it work within the plugin), I'm trying to use SoapClient by php5.

the connection seems to be working since i'm able to print out the __getFunctions() var:

StatusResponse Status(Status $parameters)" 
[1]=> string(65) "AdministrationResponse Administration(Administration $parameters)" 
[2]=> string(74) "FetchPropertyListResponse FetchPropertyList(FetchPropertyList $parameters)" 
[3]=> string(77) "FetchPropertyGroupResponse FetchPropertyGroup(FetchPropertyGroup $parameters)" 
[4]=> string(74) "FetchPropertyInfoResponse FetchPropertyInfo(FetchPropertyInfo $parameters)" 
[5]=> string(98) "FetchPropertyAvailabilityResponse FetchPropertyAvailability(FetchPropertyAvailability $parameters)" 
[6]=> string(95) "FetchPropertyRateSummaryResponse FetchPropertyRateSummary(FetchPropertyRateSummary $parameters)" 
[7]=> string(86) "FetchStayAvailabilityResponse FetchStayAvailability(FetchStayAvailability $parameters)" 
[8]=> string(71) "PlaceReservationResponse PlaceReservation(PlaceReservation $parameters)" 
[9]=> string(89) "CheckReservationExistsResponse CheckReservationExists(CheckReservationExists $parameters)" 
[10]=> string(74) "CancelReservationResponse CancelReservation(CancelReservation $parameters)" 
[11]=> string(56) "PostPaymentResponse PostPayment(PostPayment $parameters)" 
[12]=> string(53) "PostChargeResponse PostCharge(PostCharge $parameters)" 
[13]=> string(44) "PostEFTResponse PostEFT(PostEFT $parameters)" 
[14]=> string(56) "PostMessageResponse PostMessage(PostMessage $parameters)" 
[15]=> string(50) "PlaceHoldResponse PlaceHold(PlaceHold $parameters)" 
[16]=> string(53) "CancelHoldResponse CancelHold(CancelHold $parameters)" 
[17]=> string(62) "ValidateAgentResponse ValidateAgent(ValidateAgent $parameters)" 
[18]=> string(68) "ValidateCompanyResponse ValidateCompany(ValidateCompany $parameters)" 
[19]=> string(80) "FetchPropertyReportResponse FetchPropertyReport(FetchPropertyReport $parameters)" 
[20]=> string(41) "StatusResponse Status(Status $parameters)" 
[21]=> string(65) "AdministrationResponse Administration(Administration $parameters)" 
[22]=> string(74) "FetchPropertyListResponse FetchPropertyList(FetchPropertyList $parameters)" 
[23]=> string(77) "FetchPropertyGroupResponse FetchPropertyGroup(FetchPropertyGroup $parameters)" 
[24]=> string(74) "FetchPropertyInfoResponse FetchPropertyInfo(FetchPropertyInfo $parameters)" 
[25]=> string(98) "FetchPropertyAvailabilityResponse FetchPropertyAvailability(FetchPropertyAvailability $parameters)" 
[26]=> string(95) "FetchPropertyRateSummaryResponse FetchPropertyRateSummary(FetchPropertyRateSummary $parameters)" 
[27]=> string(86) "FetchStayAvailabilityResponse FetchStayAvailability(FetchStayAvailability $parameters)" 
[28]=> string(71) "PlaceReservationResponse PlaceReservation(PlaceReservation $parameters)" 
[29]=> string(89) "CheckReservationExistsResponse CheckReservationExists(CheckReservationExists $parameters)" 
[30]=> string(74) "CancelReservationResponse CancelReservation(CancelReservation $parameters)" 
[31]=> string(56) "PostPaymentResponse PostPayment(PostPayment $parameters)" 
[32]=> string(53) "PostChargeResponse PostCharge(PostCharge $parameters)" 
[33]=> string(44) "PostEFTResponse PostEFT(PostEFT $parameters)" 
[34]=> string(56) "PostMessageResponse PostMessage(PostMessage $parameters)" 
[35]=> string(50) "PlaceHoldResponse PlaceHold(PlaceHold $parameters)" 
[36]=> string(53) "CancelHoldResponse CancelHold(CancelHold $parameters)" 
[37]=> string(62) "ValidateAgentResponse ValidateAgent(ValidateAgent $parameters)" 
[38]=> string(68) "ValidateCompanyResponse ValidateCompany(ValidateCompany $parameters)" 
[39]=> string(80) "FetchPropertyReportResponse FetchPropertyReport(FetchPropertyReport $parameters)" }

When i try to call to one of the functions i get an "Object reference not set to an instance of an object." Error. I'm familiar with this error from the time before i manage to send soap request throw POSTMAN chrome plugin. i get this error when the body part was missing details.

this is the request i manage to send from POSTMAN:

<soap:Envelope xmlns:xsi="http://www.w3/2001/XMLSchema-instance"
                    xmlns:xsd="http://www.w3/2001/XMLSchema"
                    xmlns:soap="http://schemas.xmlsoap/soap/envelope/">
  <soap:Header>
    <ChannelCredentials xmlns="ChartsWeb">
      <Username>???</Username>
      <Password>???</Password>
    </ChannelCredentials>
  </soap:Header>
  <soap:Body>
    <FetchPropertyInfo xmlns="ChartsWeb">
      <FetchPropertyInfoRequest>
        <PropertyInfoRequests>
          <PropertyInfoRequest PropCode="???" MySite="???"/>
        </PropertyInfoRequests>
      </FetchPropertyInfoRequest>
    </FetchPropertyInfo>
  </soap:Body>
</soap:Envelope>

and get the expected result.

this is the current code i get :

<?php




$client = new SoapClient("http://stage-chartsweb.chartspms.au/webservices/service.asmx?wsdl", array('trace' => 1));

$ns = 'ChartsWeb'; //Namespace of the WS. 

//Body of the Soap Header. 
$headerbody = array('Username' => $username, 
                    'Password' => $password,
                    'LoggingRequest' => True);

//Create Soap Header.        
 $header = new SOAPHeader($ns, 'ChannelCredentials', $headerbody);        

// //set the Headers of Soap Client. 
 $client->__setSoapHeaders($header); 

$fcs = $client->__getFunctions();

$res_FetchPropertyInfo = $client->FetchPropertyInfo(array("PropCode" => $prop_code, "MySite" => $my_site));

var_dump($client->__getLastRequest());

and this is the request it produce:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap/soap/envelope/" xmlns:ns1="ChartsWeb">
    <SOAP-ENV:Header>
        <ns1:ChannelCredentials>
            <ns1:Username>???</ns1:Username>
            <ns1:Password>???</ns1:Password>
            <ns1:LoggingRequest>true</ns1:LoggingRequest>
        </ns1:ChannelCredentials>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:FetchPropertyInfo/>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

it seems like something with my body don't setup correctly..

anyone deal with this problem?

Share Improve this question asked Jan 13, 2017 at 11:07 bar avitalbar avital 111 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Never mind, find my error.. just need to assign to the function associate array according to the body structure. sometime all u need is just to write things down:)

本文标签: Soap web service request from wordpress plugin