3
votes

i want to change xml value in php but don't change ....

<?php

$url = "http://192.168.1.103:8080/ew.xml";
$xml = '<?xml version="1.0" ?>
<DDCConfig:getValue xmlns:DDCConfig="urn:SMUDDCConfiguration">
<DDCConfig:Network>
 <DDCConfig:LocalIP>192.168.103.223</DDCConfig:LocalIP>
 <DDCConfig:GlobalIP>168.188.127.123</DDCConfig:GlobalIP>
<DDCConfig:RootBridge>Yes</DDCConfig:RootBridge>
</DDCConfig:Network>
</DDCConfig:getValue>';

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "lmk:alrud89");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_URL, "$url"); 
curl_setopt($ch, CURLOPT_PORT, 8080);
curl_setopt($ch, CURLOPT_PUT, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS,array($xml));
$http_result = curl_exec($ch);
if($http_result){
echo $http_result;
}else{
echo curl_error($ch);
}

curl_close($ch); 
?>

error message is

* About to connect() to 192.168.1.103 port 8080 (#0) * Trying 192.168.1.103...
* connected
* Server auth using Basic with user 'lmk'
> PUT /ew.xml HTTP/1.1
> Authorization: Basic bG1rOmFscnVkODk=
> Host: 192.168.1.103:8080 Accept: /
> Transfer-Encoding: chunked
> Expect: 100-continue
< HTTP/1.1 401 Unauthorized
< Content-Length: 0
<
> WWW-Authenticate: Digest qop="auth", realm="mydomain.com", nonce="1366254379"
* HTTP error before end of send, stop sending
* Closing connection #0

what is the problem & solution?

1
is there any thing listening on that ip?user557846
One thing I can see right of the bat (not directly related to your auth error) is that you're not passing an associative array for the POST_FIELDS. Your POST data is XML, but it also needs to have a name.AgilE
@Dagon yes otherwise he would get error 404Nir Alfasi
@Dagon no...but i can see the data by firefoxuser2235070

1 Answers

2
votes

Your credentials are incorrect! (that's what error 401 means)

There's a wonderful plugin for Firefox called poster - install it and use it to double-check that the request is formatted correctly.

By the way, you might want to add the following header:

curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/xml"))

Another thing: PUT is not always supported, try POST - sometimes it'll work.