473,734 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

webservices in php

Ciary
247 Recognized Expert New Member
good morning/afternoon/evening/night fellow coders,

like a few times before i'm stuck with a problem. this time it hes everything to do with webservices or WCF.
in the end, i want to convert an xml/access/SQL database (depends on what the user uploads) to a simple multi-dimentional array.
but it isn't what i was trying to do now since i'm rather new to WCF. so, i started with a simple 'hello world'

coding the webservice wasn't difficult, but now i tried to use it in php using the next code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header('Content-Type: text/plain');
  3.  
  4. echo "WCF Test\n";
  5.  
  6. $client = new SoapClient('webservice try 1/webservice try 1/Service1.svc?wsdl');
  7.  
  8. $retval = $client->Test();
  9.  
  10. echo $retval;
  11. ?>
like you could have guessed. this didnt work. i got the next error:

-------------------------------------------------------------------------------------------------------------------
WCF Test
<br />
<b>Warning</b>: SoapClient::Soa pClient() [<a href='soapclien t.soapclient'>s oapclient.soapc lient</a>]: I/O warning : failed to load external entity &quot;webservic e try 1/webservice try 1/Service1.svc?ws dl&quot; in <b>C:\xampp\htd ocs\page\testWC F.php</b> on line <b>6</b><br />
<br />
<b>Fatal error</b>: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'webservice try 1/webservice try 1/Service1.svc?ws dl' : failed to load external entity &quot;webservic e try 1/webservice try 1/Service1.svc?ws dl&quot;
in C:\xampp\htdocs \page\testWCF.p hp:6
Stack trace:
#0 C:\xampp\htdocs \page\testWCF.p hp(6): SoapClient-&gt;SoapClient( 'webservice try ...')
#1 {main}
thrown in <b>C:\xampp\htd ocs\page\testWC F.php</b> on line <b>6</b><br />
-------------------------------------------------------------------------------------------------------------------

can anyone tell me how this should be done properly?
Apr 15 '09 #1
18 10260
Ciary
247 Recognized Expert New Member
problem solved. my url was wrong.

but now i have a new problem. 'Unsupported Media Type' on line 8

does anyone know how i can fix this?
Apr 15 '09 #2
Dormilich
8,658 Recognized Expert Moderator Expert
shouldn't be the media type of a SOAP request be "text/xml" or "applicatio n/soap+xml"?
Apr 15 '09 #3
Ciary
247 Recognized Expert New Member
if you mean that i need to change my header information, i tried that and it didn't work. also, i can connect to my web service since i can var_dump my functions:
Expand|Select|Wrap|Line Numbers
  1. var_dump($client->__getFunctions());
result:
-------------------------------------------------------------------------------------------------------------------
array(3) {
[0]=>
string(44) "GetDataRespons e GetData(GetData $parameters)"
[1]=>
string(95) "GetDataUsingDa taContractRespo nse GetDataUsingDat aContract(GetDa taUsingDataCont ract $parameters)"
[2]=>
string(35) "TestRespon se Test(Test $parameters)"
}
-------------------------------------------------------------------------------------------------------------------

but asking it to execute a function still doesn't work. even if it doesn't need parameters.

i don't know what you or the error mean by 'media type'. and i dont know how i can change it either.
Apr 15 '09 #4
Dormilich
8,658 Recognized Expert Moderator Expert
according to the manual, you call a soap function vial SoapClient::__s oapCall()
Apr 15 '09 #5
Ciary
247 Recognized Expert New Member
i know, but one of the examples on the bottom of the page says otherwise.

anyway, here is the code i tried (with __call) but it still gives the same error.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header('Content-Type: text/plain');
  3.  
  4. echo "WCF Test\n";
  5.  
  6. $client = new SoapClient('http://localhost:2024/Service1.svc?wsdl');
  7.  
  8. var_dump($client->__getFunctions());
  9.  
  10. $empty = array();
  11.  
  12. $webService = $client->__soapCall('Test', $empty);
  13. ?>
i also tried __call but it doesnt work either.
Apr 15 '09 #6
Dormilich
8,658 Recognized Expert Moderator Expert
where exactly does the function fail? is there any specific reasons given in the error message?
Apr 15 '09 #7
Ciary
247 Recognized Expert New Member
this is the full error message. i cant tell you more then this since i dont know it either. the functions i'm using are standard functions provided by visual studio 2008. i wrote the test function myself but i tried everything with both test and getData.

error message:
-------------------------------------------------------------
<br />
<b>Fatal error</b>: Uncaught SoapFault exception: [HTTP] Unsupported Media Type in C:\xampp\htdocs \page\testWCF.p hp:12
Stack trace:
#0 [internal function]: SoapClient-&gt;__doRequest ('&lt;?xml version=&quot;. ..', 'http://localhos...', 'http://tempuri....', 1, 0)
#1 C:\xampp\htdocs \page\testWCF.p hp(12): SoapClient-&gt;__soapCall( 'Test', Array)
#2 {main}
thrown in <b>C:\xampp\htd ocs\page\testWC F.php</b> on line <b>12</b><br />
---------------------------------------------------------------
Apr 15 '09 #8
Dormilich
8,658 Recognized Expert Moderator Expert
I can only guess, but it seems like the soap message transfer (HTTP) uses an inappropriate media type, there should be a documentation somewhere which states what media types are accepted by the soap recipient.

maybe the SoapVar class can help you. also read the comments in PHP's SOAP manual, maybe you find useful information there.
Apr 15 '09 #9
Ciary
247 Recognized Expert New Member
a new day and still stuck with the same problem.

like you already said. by media type they mean "applicatio n/soap + xml" but i've no idea how i could change this. the soapvar class has nothing to do with this. its just a better way to send data along with my soapcall.

can you tell me how i can change my mediatype?

edit: the next info could be more helpful:
when i used this code(see codeblock1) the connection simply times out instead of causing an error. when i tried it with 1(see codeblock2) it gave the same error as before.

cb1:
Expand|Select|Wrap|Line Numbers
  1. $wsdl_url =  "http://localhost:2024/Service1.svc?wsdl";
  2. $options = array('soap_version'   => SOAP_1_2);            //added this!!
  3. $client     = new SoapClient($wsdl_url, $options);
  4.  
  5. $params=array('value'=>'1');
  6.  
  7. try{
  8.     print_r($client->Test());
  9. }catch(SoapFault $fault){
  10.         echo ' Error Message : ',
  11.         $fault->getMessage(); 
  12. }
cb2:
Expand|Select|Wrap|Line Numbers
  1. $wsdl_url =  "http://localhost:2024/Service1.svc?wsdl";
  2. $options = array('soap_version'   => SOAP_1_1);            //changed this!!
  3. $client     = new SoapClient($wsdl_url, $options);
  4.  
  5. $params=array('value'=>'1');
  6.  
  7. try{
  8.     print_r($client->Test());
  9. }catch(SoapFault $fault){
  10.         echo ' Error Message : ',
  11.         $fault->getMessage(); 
  12. }
Apr 16 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1375
by: Jinashe | last post by:
what do i need to enable accessing of webservices from a clients PC i'm hosting some webservices from my server in VB.NET. i've got some client windows applications done in VB.NET. what have i got to install on the clients PC to be able to access these webservices?? Will just the .NET Framework suffice??? Or do i have to install SOAP?? note - the OS of the client can be win98, win2K, win3000, winXP
0
1726
by: Erik P. Vinther | last post by:
Hi This might be slightly OT, but I couldn't find a better NG for this question The question is regarding versioning of webservices. A webservice end point URL basically consists of a base company URL and a webservice name, e.g… webservices.MyCompany.com/MyService we want to be able to host several versions of a particular webservice at the same time, so we want the version id to be part of the end point URL. This is consistent...
8
1728
by: Allan Ebdrup | last post by:
I just had a discussion with one of my fellow programmers. We have a class for doing some logging and sending an email, it has 5 different scenarioes of loggin that are common enough to share a class and database tables. In the future there might be new scenarioes that require their own custom classes and database tables. Now we want to expose some of our logging class's methods as webservices (more a group of function calls called in...
5
1928
by: Stephanie Stowe | last post by:
Imagine that I had this <webServices> <soapExtensionTypes> <add type="Microsoft.Web.Services.WebServicesExtension, Microsoft.Web.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0" /> </soapExtensionTypes> </webServices>
1
1502
by: Diffident | last post by:
Hello Guys, I have a question with regards to the efficiency and best practices in .NET framework. We are currently using Webservices as normal classes. The way we are invoking methods in these Webservices is by instantiating objects of these Webservices and not by adding web references to these services... My question is "Would there be any performance or efficiency overhead, if we
5
1778
by: cyberstrike | last post by:
Hi guys, my company was wondering if it's possible to develop ASP.NET/Webservices easily using a IIS installed on a server instead of installing IIS locally on the development boxes. Can you develop for ASP.NET/Webservices without IIS installed on your local box without having to resort to more difficult debugging or using notepad for development? Thanks for the help!!
2
1979
by: Antuane | last post by:
any one have any idea how transactions could be enabled in webservices. i.e., suppose i've got 2 methods - one to add a contact, & the other to set some miscellaneous details for the contact, in a webservice. Now the client uses the above two methods & if the client is happy with the return values of the above two methdos, ONLY then are the changes made on the server to be commited. (there'd be three other methods, begin-transaction,...
1
2164
by: Mike | last post by:
Hi all, I have written a webservice which I am using in my smartphone applicaiton. I have tried the webservice with a WinForms client and it works time and time again perfectly. When I include it in my smartphone application, it will work the first time and return ther query set, however when i try it again i get the following error : "Server found request content type to be 'text/html; charset=Windows-1252', but expected 'text/xml'."
8
4011
by: Komandur Kannan | last post by:
We have a smart device application running on handhelds(Symbol MC9000G). The backend is Oracle and a middle tier web services development done in Vb.net. We use pessimistic Locking due to specific business needs When such a lock is made for a transaction (this code is in the web service) and the handhelds are terminated abnormally (cold booted or battery low), the lock still remains. The Web service's connection to oracle is still...
5
1844
by: ChrisM | last post by:
Hi, I have written a stand alone WinForms application with an MS Access back-end for the (small)company I work for. They are now talking about moving a part of their operations into a second site 50 miles away from the main one. The second site will simply be a stores. They will need some software in order to do a few things here, but this will probably come down to half a dozen or so main functions (booking stock in, issuing stock etc)
0
8951
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9458
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9187
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6743
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6040
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4818
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3266
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.