{"id":135916,"date":"2024-09-13T15:55:44","date_gmt":"2024-09-13T10:25:44","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?page_id=135916"},"modified":"2024-09-13T15:55:44","modified_gmt":"2024-09-13T10:25:44","slug":"createblog-client-implementation","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/","title":{"rendered":"CreateBlog: Client Implementation"},"content":{"rendered":"\n<p>The <code>CreateBlog<\/code> method on the client side is responsible for sending a new blog post to the server and handling the response. Here&#8217;s a detailed implementation:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. Create a Client Stub<\/strong><\/h2>\n\n\n\n<p>Create a gRPC client stub using the generated Java classes.<\/p>\n\n\n\n<p>Java<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>BlogServiceGrpc.BlogServiceBlockingStub stub = BlogServiceGrpc.newBlockingStub(channel);\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Create a BlogPost Object<\/strong><\/h2>\n\n\n\n<p>Create a <code>BlogPost<\/code> object with the desired title and content.<\/p>\n\n\n\n<p>Java<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>BlogPost blogPost = BlogPost.newBuilder()\n        .setTitle(\"My First Blog Post\")\n        .setContent(\"This is the content of my blog post.\")\n        .build();\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Call the <code>CreateBlog<\/code> Method<\/strong><\/h2>\n\n\n\n<p>Call the <code>CreateBlog<\/code> method on the client stub, passing the <code>BlogPost<\/code> object as an argument.<\/p>\n\n\n\n<p>Java<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>BlogPost response = stub.createBlogPost(blogPost);\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. Handle the Response<\/strong><\/h2>\n\n\n\n<p>Handle the response from the server. If the request was successful, the response will contain the created blog post.<\/p>\n\n\n\n<p>Java<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (response.hasId()) {\n    System.out.println(\"Blog post created successfully. ID: \" + response.getId());\n} else {\n    System.err.println(\"Error creating blog post: \" + response.getMessage());\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Complete Example<\/strong><\/p>\n\n\n\n<p>Java<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class BlogClient {\n    public static void main(String&#91;] args) throws IOException, InterruptedException {\n        ManagedChannel channel = ManagedChannelBuilder.forAddress(\"localhost\", 50051) &nbsp; \n                .usePlaintext()\n                .build();\n\n        BlogServiceGrpc.BlogServiceBlockingStub stub = BlogServiceGrpc.newBlockingStub(channel); &nbsp; \n\n        BlogPost blogPost = BlogPost.newBuilder()\n                .setTitle(\"My First Blog Post\")\n                .setContent(\"This is the content of my blog post.\")\n                .build();\n\n        BlogPost response = stub.createBlogPost(blogPost);\n\n        if (response.hasId()) {\n            System.out.println(\"Blog post created successfully. ID: \" + response.getId());\n        } else {\n            System.err.println(\"Error creating blog post: \" + response.getMessage());\n        }\n\n        channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS);\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The CreateBlog method on the client side is responsible for sending a new blog post to the server and handling the response. Here&#8217;s a detailed implementation: 1. Create a Client Stub Create a gRPC client stub using the generated Java classes. Java 2. Create a BlogPost Object Create a BlogPost object with the desired title&#8230;<\/p>\n","protected":false},"author":16,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-135916","page","type-page","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CreateBlog: Client Implementation - Tutorial<\/title>\n<meta name=\"description\" content=\"Explore how to implement the CreateBlog functionality on the client side, allowing users to seamlessly create and submit blog entries.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CreateBlog: Client Implementation - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Explore how to implement the CreateBlog functionality on the client side, allowing users to seamlessly create and submit blog entries.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/\",\"name\":\"CreateBlog: Client Implementation - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2024-09-13T10:25:44+00:00\",\"description\":\"Explore how to implement the CreateBlog functionality on the client side, allowing users to seamlessly create and submit blog entries.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CreateBlog: Client Implementation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CreateBlog: Client Implementation - Tutorial","description":"Explore how to implement the CreateBlog functionality on the client side, allowing users to seamlessly create and submit blog entries.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/","og_locale":"en_US","og_type":"article","og_title":"CreateBlog: Client Implementation - Tutorial","og_description":"Explore how to implement the CreateBlog functionality on the client side, allowing users to seamlessly create and submit blog entries.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/","name":"CreateBlog: Client Implementation - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2024-09-13T10:25:44+00:00","description":"Explore how to implement the CreateBlog functionality on the client side, allowing users to seamlessly create and submit blog entries.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/createblog-client-implementation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"CreateBlog: Client Implementation"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/135916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=135916"}],"version-history":[{"count":1,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/135916\/revisions"}],"predecessor-version":[{"id":135923,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/135916\/revisions\/135923"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=135916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=135916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=135916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}