JDEE8297
asked on
calling a web service using php
I am trying to call a dotnet webservice using php, and it has just the one method on it. and takes in the following xml string
I have the values to be filled in.
The webservice is something like this
http://ws.mydomain.com/MyContactUs.asmx?op=ProcessContactUs
And I have tried using the following call
And I am wondering if this is the correct way to call it or is there a better way of doing this?
<?xml version="1.0" encoding="utf-8"?>
<formEvent xmlns:xsi="http://www.w3.org/XMLSchema/Instance">
<FormID></FormID>
<ReqID></ReqID>
<SiteUrl></SiteUrl>
<FormData>
<EmailAddress></EmailAddress>
<EmailAddressConfirm></EmailAddressConfirm>
<ProductName></ProductName>
<ModelNumber></ModelNumber>
<Comments></Comments>
<FirstName></FirstName>
<LastName></LastName>
<Address1></Address1>
<Address2></Address2>
<City></City>
<State></State>
<Zip></Zip>
<Phone></Phone>
</FormData>
</formEvent>
I have the values to be filled in.
The webservice is something like this
http://ws.mydomain.com/MyContactUs.asmx?op=ProcessContactUs
And I have tried using the following call
function transmitsoap($url, $xmldata) {
$client = new SoapClient($url);
$result='';
//$result = $client->ProcessContactUs($xmldata);
$result = $client->ProcessSubscription($xmldata);
print $result;
return $result;
}
And I am wondering if this is the correct way to call it or is there a better way of doing this?
ASKER
@Ray
I did give you what the call the web service looks like, I can actually put the real web service in here, as it is not something I have permission to do so.
Basically, what I need to know is how you should call a web service in php, if this was in dotnet then it would be done. However, I am working with php and running into some issues that I am not totally familiar with.
This is what is returned:
Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protoc ols.SoapEx ception: Server was unable to process request. ---> System.ArgumentNullExcepti on: Value cannot be null. Parameter name: s at System.IO.StringReader..ct or(String s) at System.Xml.XmlDocument.Loa dXml(Strin g xml) at BissellForm.BissellSubscri ption.Proc essSubscri ption(Stri ng xmlRequest) --- End of inner exception stack trace
I did give you what the call the web service looks like, I can actually put the real web service in here, as it is not something I have permission to do so.
Basically, what I need to know is how you should call a web service in php, if this was in dotnet then it would be done. However, I am working with php and running into some issues that I am not totally familiar with.
This is what is returned:
Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protoc
ASKER
function transmitsoap($url, $xmldata) {
$client = new SoapClient($url);
$result='';
//$result = $client->ProcessContactUs($xmldata);
$result = $client->ProcessSubscription($xmldata);
print $result;
return $result;
}
If I call it with the above function, I get the message above.
I have another service call, that is very similar to the one above, and I am getting the same message and this is the code I am using to test it.
function transmitsoap2($url, $xmldata) {
$client = new SoapClient($url);
$email = "test@test.com";
$ishtml = true;
$action = 1;
$formid=1;
$req = "UniqueGuidID";
$site = "http://www.mydomain.com";
$result='';
//$result = $client->ProcessContactUs($xmldata);
$result = $client->ProcessSubscription(array(
"FormId"=>$formid,
"ReqId"=>$req,
"SiteUrl"=>$site,
"FormData"=> array(
"EmailAddress"=>$email,
"EmailAddressOld"=>$email,
"IsHtml"=>$ishtml,
"Action"=>$action))
);
print $result;
return $result;
}
And I get the same result as I put in my previous comment.
This is a data-dependent error. Without seeing the actual data and the actual URLs involved, we are just guessing at what might be causing your trouble. Do you not have any test case you can post here that would enable the experts to see the data and see the error in action? If you don't I strongly recommend that you set up such a test case and then post the information here so we can work with it.
Until then you might benefit from putting some data visualization techniques in place. Set error_reporting(E_ALL); and display all of the notices. Print out all of the objects and strings with var_dump(). That's about all we can tell you until you have test data for us. HTH, ~Ray
Until then you might benefit from putting some data visualization techniques in place. Set error_reporting(E_ALL); and display all of the notices. Print out all of the objects and strings with var_dump(). That's about all we can tell you until you have test data for us. HTH, ~Ray
ASKER
hmmmmm....I will see what I can do, atlhough I have to admit, usually when I post the above information that is more than enough for someone to come up with a possible solution. I have posted less information on stuff in the past, but I will see what I can do.
Just very limited in what I can do, since I have no control over the webservice and how that is written and posting in on here is not something I want to do.
If it is a case that no one can at least give me a possible way fo calling web services, or if I am calling it the incorrect way from with in PHP. Then that is a little bit of a downer...but hey, it is what it is...right. :)
Just very limited in what I can do, since I have no control over the webservice and how that is written and posting in on here is not something I want to do.
If it is a case that no one can at least give me a possible way fo calling web services, or if I am calling it the incorrect way from with in PHP. Then that is a little bit of a downer...but hey, it is what it is...right. :)
ASKER
okay, this is what happens when you deal with a web service, that you didn't write or dont have all the documentation on. You pull what hair you had left out, till there is no more to pull. :)
1. Service was tied down by ip address access.
2. and the requestid is tied down as well
so in both cases, I didn't have the right access to the service.
However, now the message that I am getting back, implies that I am not making the right call with the soapclient method.
REgardless which way I call this, I get the same message
string 'soap:Server' (length=11)
string 'System.Web.Services.Proto cols.SoapE xception: Server was unable to process request. ---> System.ArgumentNullExcepti on: Value cannot be null.
Parameter name: s
at System.IO.StringReader..ct or(String s)
at System.Xml.XmlDocument.Loa dXml(Strin g xml)
at MyClientForm.MyClientSubsc ription.Pr ocessSubsc ription(St ring xmlRequest)
--- End of inner exception stack trace ---' (length=374)
string '' (length=0)
1. Service was tied down by ip address access.
2. and the requestid is tied down as well
so in both cases, I didn't have the right access to the service.
However, now the message that I am getting back, implies that I am not making the right call with the soapclient method.
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<formEvent xmlns:xsi=\"http://www.w3.org/XMLSchema/Instance\">
<FormID>1</FormID>
<ReqID>8CB767CC-79F2-4AEE-A4EF-6C47CFA0A9C0</ReqID>
<SiteUrl>http://www.mysite.com</SiteUrl>
<FormData>
<EmailAddress>testuser@test.com</EmailAddress>
<IsHtml>true</IsHtml>
<Action>1</Action>
</FormData>
</formEvent>
";
$success = transmitsoap2($url, $xml);
function transmitsoap2($url, $xmldata) {
try {
$client = new SoapClient($url);
$email = "test@test.com";
$ishtml = true;
$action = 1;
$formid=1;
$req = "8CB767CC-79F2-4AEE-A4EF-6C47CFA0A9C0";
$site = "http://www.mysite.com";
$result='';
$result = $client->ProcessSubscription($xmldata);
/*$result = $client->ProcessSubscription(array(
"FormId"=>$formid,
"ReqId"=>$req,
"SiteUrl"=>$site,
"FormData"=> array(
"EmailAddress"=>$email,
"IsHtml"=>$ishtml,
"Action"=>$action))); */
echo $result;
print "header = ".htmlspecialchars($client->__getLastRequest());
} catch (Exception $ex) {
var_dump($ex->faultcode, $ex->faultstring, $ex->detail);
}
return $result;
}
REgardless which way I call this, I get the same message
string 'soap:Server' (length=11)
string 'System.Web.Services.Proto
Parameter name: s
at System.IO.StringReader..ct
at System.Xml.XmlDocument.Loa
at MyClientForm.MyClientSubsc
--- End of inner exception stack trace ---' (length=374)
string '' (length=0)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As I was able to solve this on my own for the most part.
If we get that information we can probably help you with this. Thanks, ~Ray