473,748 Members | 10,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why I am getting method not allowed error (405)

39 New Member
Hi,

I have a simple rest web service which is running in the Tomcat. I tested my web service successfully using REST Client for FireFox.

Now, I used PHP socket to post xml as string to my web service. But I got HTTP/1.1 405 Method Not Allowed error.

I used the following code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.     $str="<?xml version=\"1.0\"?><userEntity><address1>1300 Montecito Avenue</address1></userEntity>";
  4.  
  5.     $d="";
  6.     $fp = fsockopen("localhost", 8080, $errno, $errstr, 30);
  7.  
  8.     if (!$fp) {
  9.         echo "$errstr ($errno)<br />\n";
  10.     } else {
  11.         fputs($fp, "POST /restWS/users/ HTTP/1.1\r\n");
  12.         fputs($fp, "Host: localhost\r\n");
  13.         fputs($fp, "Content-type: text/plain\r\n");
  14.         fputs($fp, "Content-length: ".strlen($str)."\r\n");        
  15.         fputs($fp, "Connection: close\r\n\r\n");
  16.         fputs($fp, $str."\r\n\r\n"); 
  17.  
  18.  
  19.  
  20.         while(!feof($fp)){
  21.             $d .= fgets($fp);
  22.         }
  23.  
  24.         fclose($fp);                 
  25.  
  26.         echo $d;
  27.     }
  28. ?>
  29.  
I would be glad, if someone kindly help me to figure out this problem.

Thank you.
Jul 18 '10 #1
0 1732

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

Similar topics

1
2306
by: | last post by:
A friend of mine has a website that is ASP. I know nothing about ASP. He switched hosting and now his "contact us" form does not work. When you hit submit it gives an error "Error 405 Method not allowed" that "post" method is not allowed? I looked at the code which is: <form action="send_email.asp" method="post" onSubmit="return checkform();"> . Its there a file or application missing with the new hosting company? Any help would be greatly...
5
11017
by: RK | last post by:
I am getting the "HTTP /1.1 405 - method not allowed" error when I am sending XML string over Msxml2.XMLHTTP object. I am sending data in POST, also passing querystring variable and here is the code. Also error comes only sometimes. var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.Open("POST", "test.aspx?qsVar="+qsVar, false); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlhttp.Send(xmldoc);
2
17410
by: genc ymeri | last post by:
I'm uploading a text through http server but I keep getting the below error. Is the below error coming from my code or from the http server ???? Any help/tip will be very much appreciated. Thank You very much in advance. try { //create an instance of the WebClient. System.Net.WebClient MyClient = new System.Net.WebClient();
1
3173
by: Kenneth Myhra | last post by:
Hi all, while trying to convert a C++ ISAPI-filter, used to authorize file requests, to .NET we have gotten into a problem with the 'PUT' verb. First I will explain how we do this. We are implementing the IHttpModule, and mapping up the file-types in IIS to aspnet_isapi.dll by using Application mappings, so that our IHttpModule will be triggered when the specific file-type(s) is requested. You can get to these settings by displaying the...
3
2720
by: Twanger | last post by:
I'm getting a compiler error on my ASP.NET page and I can't see the cause. I have a simple C# class compiled into a DLL and placed in my bin directory which has a public property QuestionText. When I try and set the property the compiler throws up Compiler Error Message: CS1519: Invalid token '=' in class, struct, or interface member declaration If I don't try and set the property it prints out the default value of the property fine.
3
4116
by: Steve Young | last post by:
I am trying to use the webclient class in VB.Net ... in particular I want to upload a file to the web server using: dim responseArray As Byte() = myWebClient.UploadFile(uri,"POST",filename) When I try this I get Error 405 - Method Not Allowed diagnostic message. I have searched the help files in .Net and cannot find reference to this error. Can someone point in the direction of a place where I can learn more about this error ... and...
0
2925
by: John | last post by:
Hi, I am getting this error message The remote server returned an error: (405) Method Not Allowed. while trying to execute the following code: Dim myReq As HttpWebRequest = WebRequest.Create("http://127.0.0.1/virtualdirectory/")
3
5853
by: Eric | last post by:
I'm trying to test code to post xml to a web page in anticipation of a new project. I wanted to try a simple test first, but I get a (405) Method Not Allowed error no matter what I try. I have tried posting to the same machine as well as a different machine. Anonymous access is enabled for the virtual directory. I have added Allow POST for All Users for the virtual directory. I tried allow All verbs for all users but the system said that...
3
3205
by: Michael Bender | last post by:
Hello everybody, after reinstalling Windows XP (incl. IIS) it is not possible to create new webs on the local IIS in the likeweise reinstalled Visual Interdev 6.0. After typing in the name of the desired webserver (machine name or localhost) the following error comes up: "Method not allowed(Error code = 80070005)". It is however possible to create webs with Interdev on other webservers in our network. Anyone an idea? Thx Michael
0
1517
by: ppletkov | last post by:
Hi - I apologize if this is a simple question in advance :-) (hopefully it is so its quickly resolved!) i'm trying to figure out why i keep getting an error (Compile Error : expected function or variable) for my .find method. I have checked the format of this statement and it appears correct...? Dim ItemNumberWLO As String Dim ItemNumberWLN As String While Not WLO.EOF
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9238
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
6793
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
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
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
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.